public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug ada/33994]  New: wrong code for indexed component when index subtype has 'Size > 32
@ 2007-11-04 22:54 bauhaus at futureapps dot de
  2007-11-04 22:55 ` [Bug ada/33994] " bauhaus at futureapps dot de
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: bauhaus at futureapps dot de @ 2007-11-04 22:54 UTC (permalink / raw)
  To: gcc-bugs

The given program can be translated and run and it then produces
incorrect results (details below). Indeed, some circuits from the
GNAT front end seem to indicate an error (use debugging
switch -gnatdF to see this). Also, using -fstack-check adds
a warning that a frame is too large.

The assembly listing shows -1 off %ebp for the second
pair of assigments to Fst/Lst, this seems wrong.
The pairs of consequtive instructions correspond to
assignments in the respective blocks:

        movb    $33, -10002(%ebp)
        movb    $63, -2(%ebp)
...
        movb    $33, -1(%ebp)
        movb    $63, -1(%ebp)


$ ./too_big 
!?
??

To reproduce,
$ gnatmake -save-temps -gnata -gnato -gnatwa -S too_big.adb

with Ada.Text_IO;

procedure Too_Big is

        use Ada;

        type Big_Index is range 0 .. 2**50;

        type A is array (Big_Index range <>) of Character;

begin

        -- output is "!?"
        declare
                X: A (Big_Index range 2**40 .. 2**40 + 10_000);
                Fst: Character renames X(X'First);
                Lst: Character renames X(X'Last);
        begin
                Fst := '!';
                Lst := '?';

                Text_IO.Put(Fst);
                Text_IO.Put(Lst);
                Text_IO.New_Line;
        end;

        -- output is "??"
        declare
                X: A (Big_Index range 2**40 .. 2**48);
                Fst: Character renames X(X'First);
                Lst: Character renames X(X'Last);
        begin
                Fst := '!';
                Lst := '?';
                pragma assert(Fst = '!');

                Text_IO.Put(Fst);
                Text_IO.Put(Lst);
                Text_IO.New_Line;
        end;
end Too_Big;


-- 
           Summary: wrong code for indexed component when index subtype has
                    'Size > 32
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: ada
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bauhaus at futureapps dot de
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


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

* [Bug ada/33994] wrong code for indexed component when index subtype has 'Size > 32
  2007-11-04 22:54 [Bug ada/33994] New: wrong code for indexed component when index subtype has 'Size > 32 bauhaus at futureapps dot de
@ 2007-11-04 22:55 ` bauhaus at futureapps dot de
  2007-11-04 23:03 ` bauhaus at futureapps dot de
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: bauhaus at futureapps dot de @ 2007-11-04 22:55 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from bauhaus at futureapps dot de  2007-11-04 22:55 -------
$ S$ uname -a
Linux K72 2.6.22-14-generic #1 SMP Sun Oct 14 23:05:12 GMT 2007 i686 GNU/Linux

$ gnatmake -save-temps -gnata -gnato -gnatwa -S too_big.adb -cargs -v -largs -v
gcc -c -save-temps -gnata -gnato -gnatwa -S -v too_big.adb
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../gcc/configure --prefix=/opt/GCC/43
--enable-languages=c,ada,fortran
Thread model: posix
gcc version 4.3.0 20071104 (experimental) (GCC) 
COLLECT_GCC_OPTIONS='-c' '-save-temps' '-gnata' '-gnato' '-gnatwa' '-S' '-v'
'-gnatez' '-mtune=generic'
 /opt/GCC/43/libexec/gcc/i686-pc-linux-gnu/4.3.0/gnat1 -quiet -dumpbase
too_big.adb -gnata -gnato -gnatwa -gnatez -mtune=generic too_big.adb -o
too_big.s
COMPILER_PATH=/opt/GCC/43/libexec/gcc/i686-pc-linux-gnu/4.3.0/:/opt/GCC/43/libexec/gcc/i686-pc-linux-gnu/4.3.0/:/opt/GCC/43/libexec/gcc/i686-pc-linux-gnu/:/opt/GCC/43/lib/gcc/i686-pc-linux-gnu/4.3.0/:/opt/GCC/43/lib/gcc/i686-pc-linux-gnu/
LIBRARY_PATH=/opt/GCC/43/lib/gcc/i686-pc-linux-gnu/4.3.0/:/opt/GCC/43/lib/gcc/i686-pc-linux-gnu/4.3.0/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-c' '-save-temps' '-gnata' '-gnato' '-gnatwa' '-S' '-v'
'-gnatez' '-mtune=generic'
gnatbind -x too_big.ali
gnatlink too_big.ali -v

GNATLINK 4.3.0 20071104 (experimental)
Copyright (C) 1995-2007, Free Software Foundation, Inc.
gcc -c -gnatA -gnatWb -gnatiw -gnatws b~too_big.adb
/opt/GCC/43/bin/gcc b~too_big.o ./too_big.o -o too_big -L./
-L/opt/GCC/43/lib/gcc/i686-pc-linux-gnu/4.3.0/adalib/
/opt/GCC/43/lib/gcc/i686-pc-linux-gnu/4.3.0/adalib/libgnat.a -static-libgcc


-- 


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


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

* [Bug ada/33994] wrong code for indexed component when index subtype has 'Size > 32
  2007-11-04 22:54 [Bug ada/33994] New: wrong code for indexed component when index subtype has 'Size > 32 bauhaus at futureapps dot de
  2007-11-04 22:55 ` [Bug ada/33994] " bauhaus at futureapps dot de
@ 2007-11-04 23:03 ` bauhaus at futureapps dot de
  2007-11-28 22:29 ` sam at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: bauhaus at futureapps dot de @ 2007-11-04 23:03 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from bauhaus at futureapps dot de  2007-11-04 23:02 -------
Side note: With a special command line, this program
triggers a bug box with gcc 4.1.3 (Ubuntu 7.10 i686).

$ gnatmake -W -S -march=x86-64 -m64 -Os too_big.adb
gcc-4.1 -c -W -S -march=x86-64 -m64 -Os too_big.adb
+===========================GNAT BUG DETECTED==============================+
| 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu3) (i486-pc-linux-gnu) GCC
error:|
| in pro_epilogue_adjust_stack, at config/i386/i386.c:5094                 |
| Error detected at too_big.adb:41:5                                       |
| Please submit a bug report; see http://gcc.gnu.org/bugs.html.            |
| Use a subject line meaningful to you and us to track the bug.            |
| Include the entire contents of this bug box in the report.               |
| Include the exact gcc-4.1 or gnatmake command that you entered.          |
| Also include sources listed below in gnatchop format                     |
| (concatenated together with no headers between files).                   |
+==========================================================================+

Please include these source files with error report
Note that list may not be accurate in some cases, 
so please double check that the problem can still 
be reproduced with the set of files listed.

too_big.adb


raised TYPES.UNRECOVERABLE_ERROR : comperr.adb:380
gnatmake: "too_big.adb" compilation error

I cannot currently check this with a 4.3 compiler because when I
configure ... --enable-targets=all, I get

make[8]: Entering directory
`/home/georg/src/build/i686-pc-linux-gnu/64/libmudflap'
if /bin/bash ./libtool --tag=CC --mode=compile /home/georg/src/build/./gcc/xgcc
-B/home/georg/src/build/./gcc/ -B/opt/GCC/43/i686-pc-linux-gnu/bin/
-B/opt/GCC/43/i686-pc-linux-gnu/lib/ -isystem
/opt/GCC/43/i686-pc-linux-gnu/include -isystem
/opt/GCC/43/i686-pc-linux-gnu/sys-include  -m64 -DHAVE_CONFIG_H -I.
-I../../../../gcc/libmudflap -I.    -Wall -ffunction-sections -fdata-sections
-O2 -g -O2    -m64 -MT mf-runtime.lo -MD -MP -MF ".deps/mf-runtime.Tpo" -c -o
mf-runtime.lo ../../../../gcc/libmudflap/mf-runtime.c; \
        then mv -f ".deps/mf-runtime.Tpo" ".deps/mf-runtime.Plo"; else rm -f
".deps/mf-runtime.Tpo"; exit 1; fi
libtool: compile:  /home/georg/src/build/./gcc/xgcc
-B/home/georg/src/build/./gcc/ -B/opt/GCC/43/i686-pc-linux-gnu/bin/
-B/opt/GCC/43/i686-pc-linux-gnu/lib/ -isystem
/opt/GCC/43/i686-pc-linux-gnu/include -isystem
/opt/GCC/43/i686-pc-linux-gnu/sys-include -m64 -DHAVE_CONFIG_H -I.
-I../../../../gcc/libmudflap -I. -Wall -ffunction-sections -fdata-sections -O2
-g -O2 -m64 -MT mf-runtime.lo -MD -MP -MF .deps/mf-runtime.Tpo -c
../../../../gcc/libmudflap/mf-runtime.c  -fPIC -DPIC -o .libs/mf-runtime.o
../../../../gcc/libmudflap/mf-runtime.c:172: error: conflicting types for
'__mf_lc_mask'
../../../../gcc/libmudflap/mf-runtime.h:51: error: previous declaration of
'__mf_lc_mask' was here
...


-- 


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


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

* [Bug ada/33994] wrong code for indexed component when index subtype has 'Size > 32
  2007-11-04 22:54 [Bug ada/33994] New: wrong code for indexed component when index subtype has 'Size > 32 bauhaus at futureapps dot de
  2007-11-04 22:55 ` [Bug ada/33994] " bauhaus at futureapps dot de
  2007-11-04 23:03 ` bauhaus at futureapps dot de
@ 2007-11-28 22:29 ` sam at gcc dot gnu dot org
  2007-11-29 10:25 ` bauhaus at futureapps dot de
  2007-11-29 10:28 ` bauhaus at futureapps dot de
  4 siblings, 0 replies; 6+ messages in thread
From: sam at gcc dot gnu dot org @ 2007-11-28 22:29 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from sam at gcc dot gnu dot org  2007-11-28 22:29 -------
Well, what do you expect by trying to declare an array of size 2**48 - 2**40 +
1, which is much greater than the 2**32 bytes of addressable memory on your
i686-pc-linux-gnu target? :/

(2**48) % (2**32) = 0 = (2**40) % (2 ** 32), which is why you get the same
address  because of the pointer arithmetic wraparound.


-- 

sam at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |sam at gcc dot gnu dot org


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


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

* [Bug ada/33994] wrong code for indexed component when index subtype has 'Size > 32
  2007-11-04 22:54 [Bug ada/33994] New: wrong code for indexed component when index subtype has 'Size > 32 bauhaus at futureapps dot de
                   ` (2 preceding siblings ...)
  2007-11-28 22:29 ` sam at gcc dot gnu dot org
@ 2007-11-29 10:25 ` bauhaus at futureapps dot de
  2007-11-29 10:28 ` bauhaus at futureapps dot de
  4 siblings, 0 replies; 6+ messages in thread
From: bauhaus at futureapps dot de @ 2007-11-29 10:25 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from bauhaus at futureapps dot de  2007-11-29 10:25 -------
I expect that in the case described in the report (#0)
the compiler does not produce wrong code.


-- 


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


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

* [Bug ada/33994] wrong code for indexed component when index subtype has 'Size > 32
  2007-11-04 22:54 [Bug ada/33994] New: wrong code for indexed component when index subtype has 'Size > 32 bauhaus at futureapps dot de
                   ` (3 preceding siblings ...)
  2007-11-29 10:25 ` bauhaus at futureapps dot de
@ 2007-11-29 10:28 ` bauhaus at futureapps dot de
  4 siblings, 0 replies; 6+ messages in thread
From: bauhaus at futureapps dot de @ 2007-11-29 10:28 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from bauhaus at futureapps dot de  2007-11-29 10:27 -------
BTW, I have named the procedure "Too_Big" for
a reason ... :-)


-- 


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


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

end of thread, other threads:[~2007-11-29 10:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-04 22:54 [Bug ada/33994] New: wrong code for indexed component when index subtype has 'Size > 32 bauhaus at futureapps dot de
2007-11-04 22:55 ` [Bug ada/33994] " bauhaus at futureapps dot de
2007-11-04 23:03 ` bauhaus at futureapps dot de
2007-11-28 22:29 ` sam at gcc dot gnu dot org
2007-11-29 10:25 ` bauhaus at futureapps dot de
2007-11-29 10:28 ` bauhaus at futureapps dot de

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).