public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug ada/11090] New: Variant Record Initialization.
@ 2003-06-04 18:46 bdavis9659@comcast.net
2003-06-12 15:56 ` [Bug ada/11090] " pinskia@physics.uc.edu
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: bdavis9659@comcast.net @ 2003-06-04 18:46 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11090
Summary: Variant Record Initialization.
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: critical
Priority: P1
Component: ada
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: bdavis9659@comcast.net
CC: gcc-bugs@gcc.gnu.org
GCC host triplet: i386/gnu/linux
Functions used in variant record initialization are called multiple times.
FYI, the VADS ada compiler will only call the function once.
------------------------------------------------------------------------------
Here is a test case that demonstrates the problem, followed by the output:
with text_io;
procedure varrec is
type my_enum_type1 is (A1, A2, A3, A4, A5, A6);
type my_enum_type2 is (B1, B2);
type my_integer is new integer range 0..190;
type var_rec_a (sel1 : my_enum_type1 := A4; sel2 : my_enum_type2 := B2) is
record
case sel1 is
when A4 | A3 | A1 | A2 =>
case sel1 is
when A3 | A1 | A2 =>
case sel1 is
when A3 =>
case sel2 is
when B1 =>
vary : integer;
when others =>
null;
end case;
when others =>
case sel2 is
when B2 =>
var3 : my_integer;
when others =>
null;
end case;
end case;
when others =>
case sel2 is
when B2 =>
varyy : integer;
when B1 =>
varzz : integer;
end case;
end case;
when others =>
case sel2 is
when B2 =>
varyyy : integer;
when B1 =>
varzzz : integer;
end case;
end case;
end record;
type var_rec_2 (sel1 : my_enum_type1 := A4) is
record
var1 : integer;
var2 : integer;
case sel1 is
when A4 | A3 | A1 | A2 | A6 =>
var_rec_1 : var_rec_a;
when A5 =>
varx : integer;
when others =>
null;
end case;
end record;
rec1 : var_rec_2(A2);
rec2 : var_rec_2(A2);
int_cnt : my_integer := my_integer'first;
function inc_int return my_integer is
begin
text_io.put(" int_cnt was : " & my_integer'image(int_cnt));
int_cnt := int_cnt + 1;
text_io.put_line(" : is : " & my_integer'image(int_cnt) & " :");
return int_cnt;
end inc_int;
begin
text_io.new_line;
text_io.new_line;
text_io.put_line("Initializing rec1");
text_io.put_line(" Note: inc_int is unexpectedly called more than once");
text_io.put_line(" when initializing the var3 field");
rec1 := (sel1 => A2,
var1 => 123,
var_rec_1 => (sel1 => A2,
sel2 => B2,
var3 => inc_int),
var2 => 456);
text_io.put_line("Done initializing rec1");
text_io.new_line;
text_io.put_line("Initializing rec2");
text_io.put_line(" Note: inc_int is unexpectedly called more than once");
text_io.put_line(" when initializing the var3 field");
rec2 := (sel1 => A2,
var1 => 123,
var_rec_1 => (sel1 => A2,
sel2 => B2,
var3 => inc_int),
var2 => 456);
text_io.put_line("Done initializing rec2");
text_io.new_line;
text_io.put_line("Printing var3 field in rec1 and then rec2.");
text_io.put_line(" Note: This is not what was expected.");
text_io.put_line(" Only expected inc_int to be called once,");
text_io.put_line(" with returned values of 1 and 2.");
text_io.put_line("rec1.var_rec_1.var3: " &
my_integer'image(rec1.var_rec_1.var3));
text_io.put_line("rec2.var_rec_1.var3: " &
my_integer'image(rec2.var_rec_1.var3));
end varrec;
--------------------------------------------------------------------------
Here is the current output:
Initializing rec1
Note: inc_int is unexpectedly called more than once
when initializing the var3 field
int_cnt was : 0 : is : 1 :
int_cnt was : 1 : is : 2 :
int_cnt was : 2 : is : 3 :
int_cnt was : 3 : is : 4 :
int_cnt was : 4 : is : 5 :
int_cnt was : 5 : is : 6 :
int_cnt was : 6 : is : 7 :
int_cnt was : 7 : is : 8 :
int_cnt was : 8 : is : 9 :
Done initializing rec1
Initializing rec2
Note: inc_int is unexpectedly called more than once
when initializing the var3 field
int_cnt was : 9 : is : 10 :
int_cnt was : 10 : is : 11 :
int_cnt was : 11 : is : 12 :
int_cnt was : 12 : is : 13 :
int_cnt was : 13 : is : 14 :
int_cnt was : 14 : is : 15 :
int_cnt was : 15 : is : 16 :
int_cnt was : 16 : is : 17 :
int_cnt was : 17 : is : 18 :
Done initializing rec2
Printing var3 field in rec1 and then rec2.
Note: This is not what was expected.
Only expected inc_int to be called once,
with returned values of 1 and 2.
rec1.var_rec_1.var3: 1
rec2.var_rec_1.var3: 10
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug ada/11090] Variant Record Initialization.
2003-06-04 18:46 [Bug ada/11090] New: Variant Record Initialization bdavis9659@comcast.net
@ 2003-06-12 15:56 ` pinskia@physics.uc.edu
2003-07-06 4:03 ` dhazeghi at yahoo dot com
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: pinskia@physics.uc.edu @ 2003-06-12 15:56 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11090
pinskia@physics.uc.edu changed:
What |Removed |Added
----------------------------------------------------------------------------
GCC build triplet| |pc-linux-gnu
GCC host triplet|i386/gnu/linux |i386-pc-linux-gnu
GCC target triplet| |pc-linux-gnu
Priority|P1 |P2
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug ada/11090] Variant Record Initialization.
2003-06-04 18:46 [Bug ada/11090] New: Variant Record Initialization bdavis9659@comcast.net
2003-06-12 15:56 ` [Bug ada/11090] " pinskia@physics.uc.edu
@ 2003-07-06 4:03 ` dhazeghi at yahoo dot com
2003-09-13 19:03 ` bdavis9659 at comcast dot net
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: dhazeghi at yahoo dot com @ 2003-07-06 4:03 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11090
dhazeghi at yahoo dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|critical |normal
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
GCC build triplet|pc-linux-gnu |i386-pc-linux-gnu
GCC target triplet|pc-linux-gnu |i386-pc-linux-gnu
Keywords| |wrong-code
Last reconfirmed|0000-00-00 00:00:00 |2003-07-06 04:03:04
date| |
Target Milestone|3.4 |---
Version|unknown |3.3
------- Additional Comments From dhazeghi at yahoo dot com 2003-07-06 04:03 -------
Confirmed with gcc 3.3 branch and mainline (20030620).
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug ada/11090] Variant Record Initialization.
2003-06-04 18:46 [Bug ada/11090] New: Variant Record Initialization bdavis9659@comcast.net
2003-06-12 15:56 ` [Bug ada/11090] " pinskia@physics.uc.edu
2003-07-06 4:03 ` dhazeghi at yahoo dot com
@ 2003-09-13 19:03 ` bdavis9659 at comcast dot net
2003-10-21 15:48 ` charlet at gcc dot gnu dot org
2003-10-21 15:53 ` pinskia at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: bdavis9659 at comcast dot net @ 2003-09-13 19:03 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11090
------- Additional Comments From bdavis9659 at comcast dot net 2003-09-13 16:51 -------
Below is a patch that resolves this problem:
Index: gcc/gcc/ada/trans.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/ada/trans.c,v
retrieving revision 1.30
diff -c -3 -p -r1.30 trans.c
*** gcc/gcc/ada/trans.c 7 Jul 2003 17:57:27 -0000 1.30
--- gcc/gcc/ada/trans.c 13 Sep 2003 16:24:28 -0000
*************** assoc_to_constructor (gnat_assoc, gnu_ty
*** 4946,4952 ****
if (Do_Range_Check (Expression (gnat_assoc)))
gnu_expr = emit_range_check (gnu_expr, Etype (gnat_field));
! gnu_expr = convert (TREE_TYPE (gnu_field), gnu_expr);
/* Add the field and expression to the list. */
gnu_list = tree_cons (gnu_field, gnu_expr, gnu_list);
--- 4946,4952 ----
if (Do_Range_Check (Expression (gnat_assoc)))
gnu_expr = emit_range_check (gnu_expr, Etype (gnat_field));
! gnu_expr = convert (TREE_TYPE (gnu_field), protect_multiple_eval
(gnu_expr));
/* Add the field and expression to the list. */
gnu_list = tree_cons (gnu_field, gnu_expr, gnu_list);
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug ada/11090] Variant Record Initialization.
2003-06-04 18:46 [Bug ada/11090] New: Variant Record Initialization bdavis9659@comcast.net
` (2 preceding siblings ...)
2003-09-13 19:03 ` bdavis9659 at comcast dot net
@ 2003-10-21 15:48 ` charlet at gcc dot gnu dot org
2003-10-21 15:53 ` pinskia at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: charlet at gcc dot gnu dot org @ 2003-10-21 15:48 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11090
charlet at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
------- Additional Comments From charlet at gcc dot gnu dot org 2003-10-21 15:48 -------
Fixed with last Ada merge.
Arno
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug ada/11090] Variant Record Initialization.
2003-06-04 18:46 [Bug ada/11090] New: Variant Record Initialization bdavis9659@comcast.net
` (3 preceding siblings ...)
2003-10-21 15:48 ` charlet at gcc dot gnu dot org
@ 2003-10-21 15:53 ` pinskia at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-10-21 15:53 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11090
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |3.4
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2003-10-21 15:52 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-06-04 18:46 [Bug ada/11090] New: Variant Record Initialization bdavis9659@comcast.net
2003-06-12 15:56 ` [Bug ada/11090] " pinskia@physics.uc.edu
2003-07-06 4:03 ` dhazeghi at yahoo dot com
2003-09-13 19:03 ` bdavis9659 at comcast dot net
2003-10-21 15:48 ` charlet at gcc dot gnu dot org
2003-10-21 15:53 ` pinskia at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).