From: Jacob Sparre Andersen <sparre@nbi.dk>
Subject: Re: Is this a bug in my code or the compiler?
Date: Sat, 13 Jun 2015 18:43:18 +0200
Date: 2015-06-13T18:43:18+02:00 [thread overview]
Message-ID: <87oakjo8yh.fsf@adaheads.sparre-andersen.dk> (raw)
In-Reply-To: mlhhbf$fqg$1@dont-email.me
"J-P. Rosen" <rosen@adalog.fr> writes:
> Le 13/06/2015 15:33, Jacob Sparre Andersen a écrit :
>> procedure P (A, B : in out T);
>>
>> P (C, C);
>>
>> But I can't get it to complain about a simplified variation of your
>> case.
>>
>> Maybe there is an AdaControl rule to detect this kind of problem.
> Of course. It's called Parameter_Aliasing :-)
I tried it without luck on this test case:
% cat bad_style_2.adb
with Ada.Integer_Text_IO,
Ada.Text_IO;
procedure Bad_Style_2 is
function F (I : in out Integer) return Character;
function G (I : in out Integer) return String;
function F (I : in out Integer) return Character is
begin
return R : Character do
if I < 0 then
R := '-';
else
R := '+';
end if;
I := 2 * I;
end return;
end F;
function G (I : in out Integer) return String is
begin
return R : constant String := Integer'Image (I) do
I := I - 1;
end return;
end G;
C : Integer := 3;
begin
Ada.Text_IO.Put_Line (F (C) & G (C));
Ada.Integer_Text_IO.Put (C);
end Bad_Style_2;
% adactl -l 'check parameter_aliasing' bad_style_2.adb
%
I.e. no detection of "expression parameter aliasing" (or what we should
call it). I think it is only slightly harder to detect than plain
parameter aliasing, but I'm not yet quite proficient enough in ASIS to
promise to contribute a new rule to AdaControl.
Greetings,
Jacob
--
"It is very easy to get ridiculously confused about the
tenses of time travel, but most things can be resolved
by a sufficiently large ego."
next prev parent reply other threads:[~2015-06-13 16:43 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-12 15:56 Is this a bug in my code or the compiler? David Botton
2015-06-12 16:15 ` Dmitry A. Kazakov
2015-06-12 17:25 ` G.B.
2015-06-12 18:00 ` Dmitry A. Kazakov
2015-06-13 10:04 ` Georg Bauhaus
2015-06-13 10:32 ` Dmitry A. Kazakov
2015-06-15 10:37 ` G.B.
2015-06-15 12:27 ` Dmitry A. Kazakov
2015-06-15 12:31 ` Simon Wright
2015-06-15 13:16 ` Dmitry A. Kazakov
2015-06-15 14:56 ` Simon Wright
2015-06-15 15:03 ` G.B.
2015-06-13 19:42 ` Brad Moore
2015-06-12 17:53 ` David Botton
2015-06-12 18:11 ` Dmitry A. Kazakov
2015-06-12 18:43 ` marciant
2015-06-12 19:37 ` Jeffrey R. Carter
2015-06-12 19:55 ` Simon Wright
2015-06-12 20:40 ` Jeffrey R. Carter
2015-06-12 21:40 ` Simon Wright
2015-06-12 19:39 ` jan.de.kruyf
2015-06-12 22:10 ` David Botton
2015-06-13 0:19 ` Dennis Lee Bieber
2015-06-13 14:21 ` jan.de.kruyf
2015-06-14 3:13 ` Randy Brukardt
2015-06-14 3:21 ` Randy Brukardt
2015-06-12 16:48 ` Jeffrey R. Carter
2015-06-13 13:33 ` Jacob Sparre Andersen
2015-06-13 15:15 ` J-P. Rosen
2015-06-13 16:43 ` Jacob Sparre Andersen [this message]
2015-06-13 20:50 ` J-P. Rosen
2015-06-14 3:18 ` Randy Brukardt
2015-06-14 3:10 ` Randy Brukardt
2015-06-14 9:02 ` Jacob Sparre Andersen
2015-06-14 12:48 ` brbarkstrom
2015-06-15 22:06 ` Randy Brukardt
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox