public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug ada/23836] New: Invalid code generated
@ 2005-09-12 16:45 james at recherche dot enac dot fr
  2005-09-12 19:26 ` [Bug ada/23836] [4.0 Regression] Invalid code generated when accessing packed arrays laurent at guerby dot net
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: james at recherche dot enac dot fr @ 2005-09-12 16:45 UTC (permalink / raw)
  To: gcc-bugs

The gnat 4.0 compiler generates invalid code for the following program.

The output of the program is
 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
which is of course not right...
If line labelled 1 is removed and replaced by line labelled 2, the output is
correct.
The output is also correct if part 1 is replaced by part 2, while both parts are
semanticaly identical.It must also be noted that the overlay is only declared
and never used. The code is OK with gnat 3.4 

Command passed by gnat to gcc:
gcc-4.0 -c toto.adb

Result of gcc -v:
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v
--enable-languages=c,c++,java,f95,objc,ada,treelang --prefix=/usr
--enable-shared --with-system-zlib --libexecdir=/usr/lib --enable-nls
--without-included-gettext --enable-threads=posix --program-suffix=-4.0
--enable-__cxa_atexit --enable-libstdcxx-allocator=mt --enable-clocale=gnu
--enable-libstdcxx-debug --enable-java-gc=boehm --enable-java-awt=gtk
--enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-4.0-1.4.2.0/jre
--enable-mpfr --disable-werror --enable-checking=release i486-linux-gnu
Thread model: posix
gcc version 4.0.2 20050821 (prerelease) (Debian 4.0.1-6)

ADA program:

with Text_Io;
use Text_Io;
with Interfaces;
use Interfaces;


procedure Toto is
   type Intboard is new Unsigned_64;
   for Intboard'Size use 64;
   type Bit is new Integer range 0..1;
   for Bit'Size use 1;
   type Bitboard is array (0..63) of Bit;
   pragma Pack(Bitboard);
   for Bitboard'Size use 64;

   A_B : Bitboard;
   A_I : Intboard;
   for A_I'Address use A_B'Address;        --label1
--   for A_B'Address use A_I'Address;      --label2

begin
   --part 1
   for I in 0 .. 7 loop
      for J in 0 .. 7 loop
         A_B(I*8+J) := 1;
         Put(Bit'Image(A_B(I*8+J)));
      end loop;
   end loop;

   --part 2
--   for I in 0 .. 63 loop
--      A_B(I) := 1;
--      Put(Bit'Image(A_B(I)));
--   end loop;
end Toto;

-- 
           Summary: Invalid code generated
           Product: gcc
           Version: 4.0.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: ada
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: james at recherche dot enac dot fr
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23836


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug ada/23836] [4.0 Regression] Invalid code generated when accessing packed arrays
  2005-09-12 16:45 [Bug ada/23836] New: Invalid code generated james at recherche dot enac dot fr
@ 2005-09-12 19:26 ` laurent at guerby dot net
  2005-09-12 19:31 ` laurent at guerby dot net
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: laurent at guerby dot net @ 2005-09-12 19:26 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From laurent at guerby dot net  2005-09-12 19:26 -------
Works on 4.1.0 20050908, confirm problem on 4.0.1 (don't have 3.4 handy).

guerby@m:~/tmp> gcc -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: /home/guerby/work/gcc/version-head/configure
--prefix=/home/guerby/work/gcc/install/install-20050908T191957
--enable-languages=ada,c --enable-__cxa_atexit --disable-nls
--enable-threads=posix --disable-multilib --enable-checking
Thread model: posix
gcc version 4.1.0 20050908 (experimental)
guerby@m:~/tmp> gnatmake -g toto
gcc -c -g toto.adb
gnatbind -x toto.ali
gnatlink toto.ali -g
guerby@m:~/tmp> ./toto
 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

guerby@m:~/tmp> gcc -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: /home/guerby/tmp/gcc-4.0.1/configure --prefix=/opt/gcc/4.0.1
-enable-__cxa_atexit --disable-nls --enable-threads=posix --disable-multili
--enable-languages=c,ada
Thread model: posix
gcc version 4.0.1
guerby@m:~/tmp> ./toto
 0 1 1 1 0 1 1 0 0 1 1 1 0 1 1 0 0 1 1 1 0 1 1 0 0 1 1 1 0 1 1 0 0 1 1 1 0 1 1 0
0 1 1 0 1 1 1 0 0 1 1 1 0 1 1 0 0 1 1 0 1 1 1 0



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2005-09-12 19:26:49
               date|                            |
            Summary|Invalid code generated      |[4.0 Regression] Invalid
                   |                            |code generated when
                   |                            |accessing packed arrays
   Target Milestone|---                         |4.0.2


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23836


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug ada/23836] [4.0 Regression] Invalid code generated when accessing packed arrays
  2005-09-12 16:45 [Bug ada/23836] New: Invalid code generated james at recherche dot enac dot fr
  2005-09-12 19:26 ` [Bug ada/23836] [4.0 Regression] Invalid code generated when accessing packed arrays laurent at guerby dot net
@ 2005-09-12 19:31 ` laurent at guerby dot net
  2005-09-12 20:06 ` james at recherche dot enac dot fr
  2005-09-12 21:19 ` [Bug ada/23836] [4.0/4.1 Regression] Invalid code generated when accessing packed arrays / aliasing laurent at guerby dot net
  3 siblings, 0 replies; 7+ messages in thread
From: laurent at guerby dot net @ 2005-09-12 19:31 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From laurent at guerby dot net  2005-09-12 19:31 -------
>From a language point of view I doubt this construct is guaranteed to work, I'll
let someone more knowledgeable say if GCC should support this or not.

In particular at -O1 or -O2 the program fail with 4.1. Could you report with -O1
and -O2 on 3.4?


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23836


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug ada/23836] [4.0 Regression] Invalid code generated when accessing packed arrays
  2005-09-12 16:45 [Bug ada/23836] New: Invalid code generated james at recherche dot enac dot fr
  2005-09-12 19:26 ` [Bug ada/23836] [4.0 Regression] Invalid code generated when accessing packed arrays laurent at guerby dot net
  2005-09-12 19:31 ` laurent at guerby dot net
@ 2005-09-12 20:06 ` james at recherche dot enac dot fr
  2005-09-12 21:19 ` [Bug ada/23836] [4.0/4.1 Regression] Invalid code generated when accessing packed arrays / aliasing laurent at guerby dot net
  3 siblings, 0 replies; 7+ messages in thread
From: james at recherche dot enac dot fr @ 2005-09-12 20:06 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From james at recherche dot enac dot fr  2005-09-12 20:05 -------
Works perfectly well with -O1 and -O2 with gcc-3.4

There is no language trick here. The overlay A_I (which is the only tricky part)
is never used, it is only declared.

Moreover, declaring Bit as an unsigned type with modular typing as suggested by
some people in the comp.lang.ada newsgroup with 
type Bit is mod 2;
doesn't change the general behavior of the compilers.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23836


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug ada/23836] [4.0/4.1 Regression] Invalid code generated when accessing packed arrays / aliasing
  2005-09-12 16:45 [Bug ada/23836] New: Invalid code generated james at recherche dot enac dot fr
                   ` (2 preceding siblings ...)
  2005-09-12 20:06 ` james at recherche dot enac dot fr
@ 2005-09-12 21:19 ` laurent at guerby dot net
  3 siblings, 0 replies; 7+ messages in thread
From: laurent at guerby dot net @ 2005-09-12 21:19 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From laurent at guerby dot net  2005-09-12 21:18 -------
Ok I misread the code, it indeeds looks like a bug for 4.0 at -O0, and for 4.1
at -O1 and above.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kenner at vlsi1 dot ultra
                   |                            |dot nyu dot edu
           Keywords|                            |wrong-code
            Summary|[4.0 Regression] Invalid    |[4.0/4.1 Regression] Invalid
                   |code generated when         |code generated when
                   |accessing packed arrays     |accessing packed arrays /
                   |                            |aliasing
   Target Milestone|4.0.2                       |---


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23836


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug ada/23836] [4.0/4.1 Regression] Invalid code generated when accessing packed arrays / aliasing
       [not found] <bug-23836-11345@http.gcc.gnu.org/bugzilla/>
  2005-10-22 21:57 ` pinskia at gcc dot gnu dot org
@ 2005-10-30 23:31 ` pinskia at gcc dot gnu dot org
  1 sibling, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-10-30 23:31 UTC (permalink / raw)
  To: gcc-bugs



-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P2                          |P5
   Target Milestone|4.2.0                       |4.1.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23836


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug ada/23836] [4.0/4.1 Regression] Invalid code generated when accessing packed arrays / aliasing
       [not found] <bug-23836-11345@http.gcc.gnu.org/bugzilla/>
@ 2005-10-22 21:57 ` pinskia at gcc dot gnu dot org
  2005-10-30 23:31 ` pinskia at gcc dot gnu dot org
  1 sibling, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-10-22 21:57 UTC (permalink / raw)
  To: gcc-bugs



-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |critical
   Target Milestone|---                         |4.2.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23836


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2005-10-30 23:31 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-12 16:45 [Bug ada/23836] New: Invalid code generated james at recherche dot enac dot fr
2005-09-12 19:26 ` [Bug ada/23836] [4.0 Regression] Invalid code generated when accessing packed arrays laurent at guerby dot net
2005-09-12 19:31 ` laurent at guerby dot net
2005-09-12 20:06 ` james at recherche dot enac dot fr
2005-09-12 21:19 ` [Bug ada/23836] [4.0/4.1 Regression] Invalid code generated when accessing packed arrays / aliasing laurent at guerby dot net
     [not found] <bug-23836-11345@http.gcc.gnu.org/bugzilla/>
2005-10-22 21:57 ` pinskia at gcc dot gnu dot org
2005-10-30 23:31 ` 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).