public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/39333]  New: gcc 4.3.3 miscompiles when -finline-small-functions is used
@ 2009-03-01 18:18 galtgendo at o2 dot pl
  2009-03-01 18:20 ` [Bug c/39333] " galtgendo at o2 dot pl
                   ` (22 more replies)
  0 siblings, 23 replies; 33+ messages in thread
From: galtgendo at o2 dot pl @ 2009-03-01 18:18 UTC (permalink / raw)
  To: gcc-bugs

Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: /var/tmp/portage/sys-devel/gcc-4.3.3/work/gcc-4.3.3/configure
--prefix=/usr --bindir=/usr/i686-pc-linux-gnu/gcc-bin/4.3.3
--includedir=/usr/lib/gcc/i686-pc-linux-gnu/4.3.3/include
--datadir=/usr/share/gcc-data/i686-pc-linux-gnu/4.3.3
--mandir=/usr/share/gcc-data/i686-pc-linux-gnu/4.3.3/man
--infodir=/usr/share/gcc-data/i686-pc-linux-gnu/4.3.3/info
--with-gxx-include-dir=/usr/lib/gcc/i686-pc-linux-gnu/4.3.3/include/g++-v4
--host=i686-pc-linux-gnu --build=i686-pc-linux-gnu --disable-altivec
--disable-fixed-point --enable-nls --without-included-gettext
--with-system-zlib --disable-checking --disable-werror --enable-secureplt
--disable-multilib --enable-libmudflap --disable-libssp --enable-libgomp
--enable-cld --disable-libgcj --with-arch=i686 --enable-objc-gc
--enable-languages=c,c++,objc,treelang,fortran --enable-shared
--enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu
--with-bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo 4.3.3 p1.0,
pie-10.1.5'
Thread model: posix
gcc version 4.3.3 (Gentoo 4.3.3 p1.0, pie-10.1.5) 
COLLECT_GCC_OPTIONS='-DHAVE_CONFIG_H' '-I.' '-I.' '-I../..' '-I../../utility'
'-I..' '-I../../common' '-I../../intl' '-DLOCALEDIR="/usr/share/locale"'
'-DDEFAULT_DATA_PATH=".:data:~/.freeciv:/usr/share/games/freeciv"' '-Wall'
'-Wpointer-arith' '-Wcast-align' '-Wmissing-prototypes'
'-Wmissing-declarations' '-O2' '-march=athlon' '-mtune=athlon' '-pipe' '-c'
'-save-temps' '-v'
 /usr/libexec/gcc/i686-pc-linux-gnu/4.3.3/cc1 -E -quiet -v -I. -I. -I../..
-I../../utility -I.. -I../../common -I../../intl -DHAVE_CONFIG_H
-DLOCALEDIR="/usr/share/locale"
-DDEFAULT_DATA_PATH=".:data:~/.freeciv:/usr/share/games/freeciv" cm.c
-D_FORTIFY_SOURCE=2 -march=athlon -mtune=athlon -Wall -Wpointer-arith
-Wcast-align -Wmissing-prototypes -Wmissing-declarations -O2 -fpch-preprocess
-o cm.i
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory
"/usr/lib/gcc/i686-pc-linux-gnu/4.3.3/../../../../i686-pc-linux-gnu/include"
ignoring duplicate directory "."
ignoring duplicate directory "../../common"
#include "..." search starts here:
#include <...> search starts here:
 .
 ../..
 ../../utility
 ..
 ../../intl
 /usr/lib/gcc/i686-pc-linux-gnu/4.3.3/include
 /usr/lib/gcc/i686-pc-linux-gnu/4.3.3/include-fixed
 /usr/include
End of search list.
COLLECT_GCC_OPTIONS='-DHAVE_CONFIG_H' '-I.' '-I.' '-I../..' '-I../../utility'
'-I..' '-I../../common' '-I../../intl' '-DLOCALEDIR="/usr/share/locale"'
'-DDEFAULT_DATA_PATH=".:data:~/.freeciv:/usr/share/games/freeciv"' '-Wall'
'-Wpointer-arith' '-Wcast-align' '-Wmissing-prototypes'
'-Wmissing-declarations' '-O2' '-march=athlon' '-mtune=athlon' '-pipe' '-c'
'-save-temps' '-v'
 /usr/libexec/gcc/i686-pc-linux-gnu/4.3.3/cc1 -fpreprocessed cm.i -quiet
-dumpbase cm.c -march=athlon -mtune=athlon -auxbase cm -O2 -Wall
-Wpointer-arith -Wcast-align -Wmissing-prototypes -Wmissing-declarations
-version -o cm.s
GNU C (Gentoo 4.3.3 p1.0, pie-10.1.5) version 4.3.3 (i686-pc-linux-gnu)
        compiled by GNU C version 4.3.3, GMP version 4.2.4, MPFR version 2.3.2.
GGC heuristics: --param ggc-min-expand=64 --param ggc-min-heapsize=64090
Compiler executable checksum: 3bb01a6c568a839db7333dbf97a76459
COLLECT_GCC_OPTIONS='-DHAVE_CONFIG_H' '-I.' '-I.' '-I../..' '-I../../utility'
'-I..' '-I../../common' '-I../../intl' '-DLOCALEDIR="/usr/share/locale"'
'-DDEFAULT_DATA_PATH=".:data:~/.freeciv:/usr/share/games/freeciv"' '-Wall'
'-Wpointer-arith' '-Wcast-align' '-Wmissing-prototypes'
'-Wmissing-declarations' '-O2' '-march=athlon' '-mtune=athlon' '-pipe' '-c'
'-save-temps' '-v'
 /usr/lib/gcc/i686-pc-linux-gnu/4.3.3/../../../../i686-pc-linux-gnu/bin/as -V
-Qy -o cm.o cm.s
GNU assembler version 2.19 (i686-pc-linux-gnu) using BFD version (GNU Binutils)
2.19
COMPILER_PATH=/usr/libexec/gcc/i686-pc-linux-gnu/4.3.3/:/usr/libexec/gcc/i686-pc-linux-gnu/4.3.3/:/usr/libexec/gcc/i686-pc-linux-gnu/:/usr/lib/gcc/i686-pc-linux-gnu/4.3.3/:/usr/lib/gcc/i686-pc-linux-gnu/:/usr/libexec/gcc/i686-pc-linux-gnu/4.3.3/:/usr/libexec/gcc/i686-pc-linux-gnu/:/usr/lib/gcc/i686-pc-linux-gnu/4.3.3/:/usr/lib/gcc/i686-pc-linux-gnu/:/usr/lib/gcc/i686-pc-linux-gnu/4.3.3/../../../../i686-pc-linux-gnu/bin/
LIBRARY_PATH=/usr/lib/gcc/i686-pc-linux-gnu/4.3.3/:/usr/lib/gcc/i686-pc-linux-gnu/4.3.3/:/usr/lib/gcc/i686-pc-linux-gnu/4.3.3/../../../../i686-pc-linux-gnu/lib/:/usr/lib/gcc/i686-pc-linux-gnu/4.3.3/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-DHAVE_CONFIG_H' '-I.' '-I.' '-I../..' '-I../../utility'
'-I..' '-I../../common' '-I../../intl' '-DLOCALEDIR="/usr/share/locale"'
'-DDEFAULT_DATA_PATH=".:data:~/.freeciv:/usr/share/games/freeciv"' '-Wall'
'-Wpointer-arith' '-Wcast-align' '-Wmissing-prototypes'
'-Wmissing-declarations' '-O2' '-march=athlon' '-mtune=athlon' '-pipe' '-c'
'-save-temps' '-v'

Now, I'm not sure, whether this file is the correct one, as freeciv is quite
big, but http://bugs.freeciv.org/Ticket/Display.html?id=40610 seems to suggest
that this is the correct one.
I'm not sure, whether or not upstream has opened a bug here already, as I'm not
sure,
what search terms should I use.


-- 
           Summary: gcc 4.3.3 miscompiles when -finline-small-functions is
                    used
           Product: gcc
           Version: 4.3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: galtgendo at o2 dot pl


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


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

* [Bug c/39333] gcc 4.3.3 miscompiles when -finline-small-functions is used
  2009-03-01 18:18 [Bug c/39333] New: gcc 4.3.3 miscompiles when -finline-small-functions is used galtgendo at o2 dot pl
@ 2009-03-01 18:20 ` galtgendo at o2 dot pl
  2009-03-02 13:52 ` [Bug middle-end/39333] " pinskia at gcc dot gnu dot org
                   ` (21 subsequent siblings)
  22 siblings, 0 replies; 33+ messages in thread
From: galtgendo at o2 dot pl @ 2009-03-01 18:20 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from galtgendo at o2 dot pl  2009-03-01 18:19 -------
Created an attachment (id=17381)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=17381&action=view)
preprocessed file


-- 


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


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

* [Bug middle-end/39333] gcc 4.3.3 miscompiles when -finline-small-functions is used
  2009-03-01 18:18 [Bug c/39333] New: gcc 4.3.3 miscompiles when -finline-small-functions is used galtgendo at o2 dot pl
  2009-03-01 18:20 ` [Bug c/39333] " galtgendo at o2 dot pl
@ 2009-03-02 13:52 ` pinskia at gcc dot gnu dot org
  2009-03-02 21:56 ` galtgendo at o2 dot pl
                   ` (20 subsequent siblings)
  22 siblings, 0 replies; 33+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-03-02 13:52 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2009-03-02 13:52 -------
Does -fno-strict-aliasing help ?
Does -fno-strict-overflow help?


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c                           |middle-end


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


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

* [Bug middle-end/39333] gcc 4.3.3 miscompiles when -finline-small-functions is used
  2009-03-01 18:18 [Bug c/39333] New: gcc 4.3.3 miscompiles when -finline-small-functions is used galtgendo at o2 dot pl
  2009-03-01 18:20 ` [Bug c/39333] " galtgendo at o2 dot pl
  2009-03-02 13:52 ` [Bug middle-end/39333] " pinskia at gcc dot gnu dot org
@ 2009-03-02 21:56 ` galtgendo at o2 dot pl
  2009-03-02 22:20 ` galtgendo at o2 dot pl
                   ` (19 subsequent siblings)
  22 siblings, 0 replies; 33+ messages in thread
From: galtgendo at o2 dot pl @ 2009-03-02 21:56 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from galtgendo at o2 dot pl  2009-03-02 21:56 -------
I'll check, but, as summary suggests (indirectly),
'-O2 -fno-inline-small-functions' works just fine.


-- 


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


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

* [Bug middle-end/39333] gcc 4.3.3 miscompiles when -finline-small-functions is used
  2009-03-01 18:18 [Bug c/39333] New: gcc 4.3.3 miscompiles when -finline-small-functions is used galtgendo at o2 dot pl
                   ` (2 preceding siblings ...)
  2009-03-02 21:56 ` galtgendo at o2 dot pl
@ 2009-03-02 22:20 ` galtgendo at o2 dot pl
  2009-03-02 22:43 ` pinskia at gcc dot gnu dot org
                   ` (18 subsequent siblings)
  22 siblings, 0 replies; 33+ messages in thread
From: galtgendo at o2 dot pl @ 2009-03-02 22:20 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from galtgendo at o2 dot pl  2009-03-02 22:20 -------
Well, neither helps.
As a sidenote: 'gcc -Q -O2 --help=optimizers' fails to list
'-fstrict-overflow',


-- 


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


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

* [Bug middle-end/39333] gcc 4.3.3 miscompiles when -finline-small-functions is used
  2009-03-01 18:18 [Bug c/39333] New: gcc 4.3.3 miscompiles when -finline-small-functions is used galtgendo at o2 dot pl
                   ` (3 preceding siblings ...)
  2009-03-02 22:20 ` galtgendo at o2 dot pl
@ 2009-03-02 22:43 ` pinskia at gcc dot gnu dot org
  2009-03-03  0:20 ` galtgendo at o2 dot pl
                   ` (17 subsequent siblings)
  22 siblings, 0 replies; 33+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-03-02 22:43 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from pinskia at gcc dot gnu dot org  2009-03-02 22:43 -------
(In reply to comment #3)
> I'll check, but, as summary suggests (indirectly),
> '-O2 -fno-inline-small-functions' works just fine.

But that just enables more inlining.  The problem is most likely somewhere
else.


-- 


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


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

* [Bug middle-end/39333] gcc 4.3.3 miscompiles when -finline-small-functions is used
  2009-03-01 18:18 [Bug c/39333] New: gcc 4.3.3 miscompiles when -finline-small-functions is used galtgendo at o2 dot pl
                   ` (4 preceding siblings ...)
  2009-03-02 22:43 ` pinskia at gcc dot gnu dot org
@ 2009-03-03  0:20 ` galtgendo at o2 dot pl
  2009-03-03  0:21 ` pinskia at gcc dot gnu dot org
                   ` (16 subsequent siblings)
  22 siblings, 0 replies; 33+ messages in thread
From: galtgendo at o2 dot pl @ 2009-03-03  0:20 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from galtgendo at o2 dot pl  2009-03-03 00:20 -------
(In reply to comment #5)
> But that just enables more inlining.  The problem is most likely somewhere
> else.
> 
If so, why does '-O2' fail and '-O2 -fno-inline-small-functions' work ?


-- 


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


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

* [Bug middle-end/39333] gcc 4.3.3 miscompiles when -finline-small-functions is used
  2009-03-01 18:18 [Bug c/39333] New: gcc 4.3.3 miscompiles when -finline-small-functions is used galtgendo at o2 dot pl
                   ` (5 preceding siblings ...)
  2009-03-03  0:20 ` galtgendo at o2 dot pl
@ 2009-03-03  0:21 ` pinskia at gcc dot gnu dot org
  2009-03-03  3:23 ` galtgendo at o2 dot pl
                   ` (15 subsequent siblings)
  22 siblings, 0 replies; 33+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-03-03  0:21 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from pinskia at gcc dot gnu dot org  2009-03-03 00:21 -------
(In reply to comment #6)
> If so, why does '-O2' fail and '-O2 -fno-inline-small-functions' work ?

Because you just disabled some extra inlining.  try -O2
-fno-inline-small-functions -finline-functions and you will see that it still
fails.

-- Pinski


-- 


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


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

* [Bug middle-end/39333] gcc 4.3.3 miscompiles when -finline-small-functions is used
  2009-03-01 18:18 [Bug c/39333] New: gcc 4.3.3 miscompiles when -finline-small-functions is used galtgendo at o2 dot pl
                   ` (6 preceding siblings ...)
  2009-03-03  0:21 ` pinskia at gcc dot gnu dot org
@ 2009-03-03  3:23 ` galtgendo at o2 dot pl
  2009-03-03  3:43 ` galtgendo at o2 dot pl
                   ` (14 subsequent siblings)
  22 siblings, 0 replies; 33+ messages in thread
From: galtgendo at o2 dot pl @ 2009-03-03  3:23 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from galtgendo at o2 dot pl  2009-03-03 03:23 -------
OK, we seem to misunderstand each other.

Anyway, as '-Wall -Wpointer-arith
-Wcast-align -Wmissing-prototypes -Wmissing-declarations'
was set for all files during build and there were no warnings,
the problem is probably non-trivial (though seeing just how
much inlining is used is this file, I wouldn't be surprised,
if it's 50/50 on gcc/freeciv).
When I added '-Wextra', most of the new warnings were of either
'unused argument' or 'signed/unsinged comparison' type - in this
file, there were no other.


-- 


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


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

* [Bug middle-end/39333] gcc 4.3.3 miscompiles when -finline-small-functions is used
  2009-03-01 18:18 [Bug c/39333] New: gcc 4.3.3 miscompiles when -finline-small-functions is used galtgendo at o2 dot pl
                   ` (7 preceding siblings ...)
  2009-03-03  3:23 ` galtgendo at o2 dot pl
@ 2009-03-03  3:43 ` galtgendo at o2 dot pl
  2009-03-03  3:51 ` pinskia at gcc dot gnu dot org
                   ` (13 subsequent siblings)
  22 siblings, 0 replies; 33+ messages in thread
From: galtgendo at o2 dot pl @ 2009-03-03  3:43 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from galtgendo at o2 dot pl  2009-03-03 03:43 -------
BTW, this is the workaround, that upstream created:
http://svn.gna.org/viewcvs/freeciv/trunk/common/aicore/cm.c?rev=15556&view=diff&r1=15556&r2=15555&p1=trunk/common/aicore/cm.c&p2=/trunk/common/aicore/cm.c


-- 


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


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

* [Bug middle-end/39333] gcc 4.3.3 miscompiles when -finline-small-functions is used
  2009-03-01 18:18 [Bug c/39333] New: gcc 4.3.3 miscompiles when -finline-small-functions is used galtgendo at o2 dot pl
                   ` (8 preceding siblings ...)
  2009-03-03  3:43 ` galtgendo at o2 dot pl
@ 2009-03-03  3:51 ` pinskia at gcc dot gnu dot org
  2009-03-03 15:15 ` galtgendo at o2 dot pl
                   ` (12 subsequent siblings)
  22 siblings, 0 replies; 33+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-03-03  3:51 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from pinskia at gcc dot gnu dot org  2009-03-03 03:51 -------
   for (i = 0, j = 0; i < lattice->size || forced_loop; i++) {


i is signed and lattice->size is unsigned so there might be some wrapping.  

plus  if (lattice->size > 0) { 
will be changed into   lattice->size != 0 .


-- 


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


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

* [Bug middle-end/39333] gcc 4.3.3 miscompiles when -finline-small-functions is used
  2009-03-01 18:18 [Bug c/39333] New: gcc 4.3.3 miscompiles when -finline-small-functions is used galtgendo at o2 dot pl
                   ` (9 preceding siblings ...)
  2009-03-03  3:51 ` pinskia at gcc dot gnu dot org
@ 2009-03-03 15:15 ` galtgendo at o2 dot pl
  2009-03-03 16:17 ` galtgendo at o2 dot pl
                   ` (11 subsequent siblings)
  22 siblings, 0 replies; 33+ messages in thread
From: galtgendo at o2 dot pl @ 2009-03-03 15:15 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #11 from galtgendo at o2 dot pl  2009-03-03 15:15 -------
Changing those two to unsigned doesn't help (I have checked that
even before comment 8). Actually, I changed a few ints to unsigned
wherever it looked sane for this file and it still crashed.

What's more, '-O1' works and when I decided to go down the man page
and test by -fno-* all of the features listed as additionally
turned on by -O2
(-fthread-jumps -falign-functions  -falign-jumps -falign-loops  -falign-labels
-fcaller-saves -fcrossjumping -fcse-follow-jumps  -fcse-skip-blocks
-fdelete-null-pointer-checks -fexpensive-optimizations -fgcse
-fgcse-lm -foptimize-sibling-calls -fpeephole2 -fregmove
-freorder-blocks  -freorder-functions -frerun-cse-after-loop
-fsched-interblock  -fsched-spec -fschedule-insns
-fschedule-insns2 -fstrict-aliasing -fstrict-overflow -ftree-pre
-ftree-vrp) neither of them worked on its own.


-- 


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


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

* [Bug middle-end/39333] gcc 4.3.3 miscompiles when -finline-small-functions is used
  2009-03-01 18:18 [Bug c/39333] New: gcc 4.3.3 miscompiles when -finline-small-functions is used galtgendo at o2 dot pl
                   ` (10 preceding siblings ...)
  2009-03-03 15:15 ` galtgendo at o2 dot pl
@ 2009-03-03 16:17 ` galtgendo at o2 dot pl
  2009-03-03 16:22 ` galtgendo at o2 dot pl
                   ` (10 subsequent siblings)
  22 siblings, 0 replies; 33+ messages in thread
From: galtgendo at o2 dot pl @ 2009-03-03 16:17 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #12 from galtgendo at o2 dot pl  2009-03-03 16:17 -------
OK, a (perhaps) interesting result:
'-fno-guess-branch-probability' works too, but
as first to work was '-fno-inline-small-functions',
this may simply be a case of this option making code
big enough to hit inlining limit.


-- 


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


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

* [Bug middle-end/39333] gcc 4.3.3 miscompiles when -finline-small-functions is used
  2009-03-01 18:18 [Bug c/39333] New: gcc 4.3.3 miscompiles when -finline-small-functions is used galtgendo at o2 dot pl
                   ` (11 preceding siblings ...)
  2009-03-03 16:17 ` galtgendo at o2 dot pl
@ 2009-03-03 16:22 ` galtgendo at o2 dot pl
  2009-03-03 17:01 ` hjl dot tools at gmail dot com
                   ` (9 subsequent siblings)
  22 siblings, 0 replies; 33+ messages in thread
From: galtgendo at o2 dot pl @ 2009-03-03 16:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #13 from galtgendo at o2 dot pl  2009-03-03 16:22 -------
On a not really related note:
output of 'gcc -Q -O1 --help=optimizers' is quite inconsistent
with the manpage. Among others, -finline-small-functions according
to the manpage is turned on for -O1, -Q output claims the opposite.


-- 


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


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

* [Bug middle-end/39333] gcc 4.3.3 miscompiles when -finline-small-functions is used
  2009-03-01 18:18 [Bug c/39333] New: gcc 4.3.3 miscompiles when -finline-small-functions is used galtgendo at o2 dot pl
                   ` (12 preceding siblings ...)
  2009-03-03 16:22 ` galtgendo at o2 dot pl
@ 2009-03-03 17:01 ` hjl dot tools at gmail dot com
  2009-03-03 21:13 ` galtgendo at o2 dot pl
                   ` (8 subsequent siblings)
  22 siblings, 0 replies; 33+ messages in thread
From: hjl dot tools at gmail dot com @ 2009-03-03 17:01 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #14 from hjl dot tools at gmail dot com  2009-03-03 17:01 -------
Is there a testcase to show run-time error or compile-time error?


-- 


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


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

* [Bug middle-end/39333] gcc 4.3.3 miscompiles when -finline-small-functions is used
  2009-03-01 18:18 [Bug c/39333] New: gcc 4.3.3 miscompiles when -finline-small-functions is used galtgendo at o2 dot pl
                   ` (13 preceding siblings ...)
  2009-03-03 17:01 ` hjl dot tools at gmail dot com
@ 2009-03-03 21:13 ` galtgendo at o2 dot pl
  2009-03-07  4:30 ` galtgendo at o2 dot pl
                   ` (7 subsequent siblings)
  22 siblings, 0 replies; 33+ messages in thread
From: galtgendo at o2 dot pl @ 2009-03-03 21:13 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #15 from galtgendo at o2 dot pl  2009-03-03 21:13 -------
It's a runtime error and there's no real testcase,
as, for the time being, it's hard to say what exactly goes wrong.

The only real analysis is in the upstream bug, but it's nothing conclusive
(at least it doesn't seem that way).


-- 


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


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

* [Bug middle-end/39333] gcc 4.3.3 miscompiles when -finline-small-functions is used
  2009-03-01 18:18 [Bug c/39333] New: gcc 4.3.3 miscompiles when -finline-small-functions is used galtgendo at o2 dot pl
                   ` (14 preceding siblings ...)
  2009-03-03 21:13 ` galtgendo at o2 dot pl
@ 2009-03-07  4:30 ` galtgendo at o2 dot pl
  2009-03-07  4:35   ` Andrew Thomas Pinski
  2009-03-07  4:36 ` pinskia at gmail dot com
                   ` (6 subsequent siblings)
  22 siblings, 1 reply; 33+ messages in thread
From: galtgendo at o2 dot pl @ 2009-03-07  4:30 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #16 from galtgendo at o2 dot pl  2009-03-07 04:30 -------
OK, I've done a little test and I'd like to know,
if it's results actually mean anything:
I've compiled freeciv with CFLAGS="-O2 -finline-functions
-fno-guess-branch-probability" and it did not crash.

Does the above confirm that the problem lies in -fguess-branch-probability ?


-- 


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


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

* Re: [Bug middle-end/39333] gcc 4.3.3 miscompiles when -finline-small-functions is used
  2009-03-07  4:30 ` galtgendo at o2 dot pl
@ 2009-03-07  4:35   ` Andrew Thomas Pinski
  0 siblings, 0 replies; 33+ messages in thread
From: Andrew Thomas Pinski @ 2009-03-07  4:35 UTC (permalink / raw)
  To: gcc-bugzilla; +Cc: gcc-bugs



Sent from my iPhone

On Mar 6, 2009, at 8:30 PM, "galtgendo at o2 dot pl" <gcc-bugzilla@gcc.gnu.org 
 > wrote:

>
>
> ------- Comment #16 from galtgendo at o2 dot pl  2009-03-07 04:30  
> -------
> OK, I've done a little test and I'd like to know,
> if it's results actually mean anything:
> I've compiled freeciv with CFLAGS="-O2 -finline-functions
> -fno-guess-branch-probability" and it did not crash.
>
> Does the above confirm that the problem lies in -fguess-branch- 
> probability ?

Not really because that option only generates information used by  
other optimazations.

>
>
>
> -- 
>
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39333
>


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

* [Bug middle-end/39333] gcc 4.3.3 miscompiles when -finline-small-functions is used
  2009-03-01 18:18 [Bug c/39333] New: gcc 4.3.3 miscompiles when -finline-small-functions is used galtgendo at o2 dot pl
                   ` (15 preceding siblings ...)
  2009-03-07  4:30 ` galtgendo at o2 dot pl
@ 2009-03-07  4:36 ` pinskia at gmail dot com
  2009-03-07 14:06 ` galtgendo at o2 dot pl
                   ` (5 subsequent siblings)
  22 siblings, 0 replies; 33+ messages in thread
From: pinskia at gmail dot com @ 2009-03-07  4:36 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #17 from pinskia at gmail dot com  2009-03-07 04:35 -------
Subject: Re:  gcc 4.3.3 miscompiles when -finline-small-functions is used



Sent from my iPhone

On Mar 6, 2009, at 8:30 PM, "galtgendo at o2 dot pl" <gcc-bugzilla@gcc.gnu.org 
 > wrote:

>
>
> ------- Comment #16 from galtgendo at o2 dot pl  2009-03-07 04:30  
> -------
> OK, I've done a little test and I'd like to know,
> if it's results actually mean anything:
> I've compiled freeciv with CFLAGS="-O2 -finline-functions
> -fno-guess-branch-probability" and it did not crash.
>
> Does the above confirm that the problem lies in -fguess-branch- 
> probability ?

Not really because that option only generates information used by  
other optimazations.

>
>
>
> -- 
>
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39333
>


-- 


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


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

* [Bug middle-end/39333] gcc 4.3.3 miscompiles when -finline-small-functions is used
  2009-03-01 18:18 [Bug c/39333] New: gcc 4.3.3 miscompiles when -finline-small-functions is used galtgendo at o2 dot pl
                   ` (16 preceding siblings ...)
  2009-03-07  4:36 ` pinskia at gmail dot com
@ 2009-03-07 14:06 ` galtgendo at o2 dot pl
  2009-03-16 10:24 ` falk at debian dot org
                   ` (4 subsequent siblings)
  22 siblings, 0 replies; 33+ messages in thread
From: galtgendo at o2 dot pl @ 2009-03-07 14:06 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #18 from galtgendo at o2 dot pl  2009-03-07 14:06 -------
Well, I've got bad news for you anyway:
it seems that the problem affects gcc-4.3.2 too:
it seems it's reproducible in another app,
however one potentially much harder to debug.
Please read http://bugs.winehq.org/show_bug.cgi?id=17406
and give some ideas for a test.


-- 


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


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

* [Bug middle-end/39333] gcc 4.3.3 miscompiles when -finline-small-functions is used
  2009-03-01 18:18 [Bug c/39333] New: gcc 4.3.3 miscompiles when -finline-small-functions is used galtgendo at o2 dot pl
                   ` (17 preceding siblings ...)
  2009-03-07 14:06 ` galtgendo at o2 dot pl
@ 2009-03-16 10:24 ` falk at debian dot org
  2009-04-22  0:04 ` galtgendo at o2 dot pl
                   ` (3 subsequent siblings)
  22 siblings, 0 replies; 33+ messages in thread
From: falk at debian dot org @ 2009-03-16 10:24 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #19 from falk at debian dot org  2009-03-16 10:24 -------
(In reply to comment #18)
> Well, I've got bad news for you anyway:
> it seems that the problem affects gcc-4.3.2 too:
> it seems it's reproducible in another app,
> however one potentially much harder to debug.
> Please read http://bugs.winehq.org/show_bug.cgi?id=17406
> and give some ideas for a test.

The fact that -fno-inline helps gives only very little indication that this is
actually the same problem.

In any case, I don't think there's really anything we can do without a complete
test case (that is, a single file with a main() that exits with 0 when
everything's fine and 1 otherwise). This is very difficult to do for someone
who doesn't know the freeciv codebase.


-- 

falk at debian dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING


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


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

* [Bug middle-end/39333] gcc 4.3.3 miscompiles when -finline-small-functions is used
  2009-03-01 18:18 [Bug c/39333] New: gcc 4.3.3 miscompiles when -finline-small-functions is used galtgendo at o2 dot pl
                   ` (18 preceding siblings ...)
  2009-03-16 10:24 ` falk at debian dot org
@ 2009-04-22  0:04 ` galtgendo at o2 dot pl
  2009-04-22  0:23 ` galtgendo at o2 dot pl
                   ` (2 subsequent siblings)
  22 siblings, 0 replies; 33+ messages in thread
From: galtgendo at o2 dot pl @ 2009-04-22  0:04 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #20 from galtgendo at o2 dot pl  2009-04-22 00:04 -------
Created an attachment (id=17669)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=17669&action=view)
prepocessed source of id.c

People, I've got a result, that's either very funny or very not funny.
With the same compiler, with the command "i686-pc-linux-gnu-gcc -std=gnu99 -O2
-march=athlon -mtune=athlon -pipe -fno-guess-branch-probability -I../lib -o id
id.c group-list.o libver.a ../lib/libcoreutils.a"
id.c from coreutils 7.2 gets miscompiled, resulting in "id -u" always printing
"id: cannot print "only" of more than one choice"
The "funny" part is that without "-fno-guess-branch-probability" it works
correctly, so it's the (sort of) opposite of above.
I will shortly test, if things change with gcc 4.4.0.


-- 


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


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

* [Bug middle-end/39333] gcc 4.3.3 miscompiles when -finline-small-functions is used
  2009-03-01 18:18 [Bug c/39333] New: gcc 4.3.3 miscompiles when -finline-small-functions is used galtgendo at o2 dot pl
                   ` (19 preceding siblings ...)
  2009-04-22  0:04 ` galtgendo at o2 dot pl
@ 2009-04-22  0:23 ` galtgendo at o2 dot pl
  2009-04-22  1:08 ` galtgendo at o2 dot pl
  2009-04-22  1:15 ` galtgendo at o2 dot pl
  22 siblings, 0 replies; 33+ messages in thread
From: galtgendo at o2 dot pl @ 2009-04-22  0:23 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #21 from galtgendo at o2 dot pl  2009-04-22 00:23 -------
Well, with 4.4.0 id.c compiles correctly in both cases.
Let's check the harder part.


-- 


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


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

* [Bug middle-end/39333] gcc 4.3.3 miscompiles when -finline-small-functions is used
  2009-03-01 18:18 [Bug c/39333] New: gcc 4.3.3 miscompiles when -finline-small-functions is used galtgendo at o2 dot pl
                   ` (20 preceding siblings ...)
  2009-04-22  0:23 ` galtgendo at o2 dot pl
@ 2009-04-22  1:08 ` galtgendo at o2 dot pl
  2009-04-22  1:15 ` galtgendo at o2 dot pl
  22 siblings, 0 replies; 33+ messages in thread
From: galtgendo at o2 dot pl @ 2009-04-22  1:08 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #22 from galtgendo at o2 dot pl  2009-04-22 01:08 -------
Well, gcc 4.4.0 works without '-fno-inline-small-functions' for
freeciv too.


-- 


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


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

* [Bug middle-end/39333] gcc 4.3.3 miscompiles when -finline-small-functions is used
  2009-03-01 18:18 [Bug c/39333] New: gcc 4.3.3 miscompiles when -finline-small-functions is used galtgendo at o2 dot pl
                   ` (21 preceding siblings ...)
  2009-04-22  1:08 ` galtgendo at o2 dot pl
@ 2009-04-22  1:15 ` galtgendo at o2 dot pl
  22 siblings, 0 replies; 33+ messages in thread
From: galtgendo at o2 dot pl @ 2009-04-22  1:15 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #23 from galtgendo at o2 dot pl  2009-04-22 01:15 -------
comment 22 was of course about '-fno-guess-branch-probability',
not the other one.


-- 


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


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

* [Bug middle-end/39333] gcc 4.3.3 miscompiles when -finline-small-functions is used
       [not found] <bug-39333-4@http.gcc.gnu.org/bugzilla/>
                   ` (6 preceding siblings ...)
  2013-01-06  2:20 ` galtgendo at o2 dot pl
@ 2013-01-06  3:34 ` galtgendo at o2 dot pl
  7 siblings, 0 replies; 33+ messages in thread
From: galtgendo at o2 dot pl @ 2013-01-06  3:34 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #31 from Rafał Mużyło <galtgendo at o2 dot pl> 2013-01-06 03:34:17 UTC ---
PS: the stripped down test case from PR33763 is quite alike attachment 25239,
yet something makes a difference.

extern void *bar (void);
extern int baz (void);

extern __inline __attribute__ ((__always_inline__))int
baz (void)
{
  return 2;
}

int
baz (void)
{
  return 1;
}

static void *
inl (void)
{
  int *f = (int *) __builtin_malloc (sizeof (int));
  void *r = 0;

  *f = baz();
  r = bar();
  return r;
}

void *
foo (void)
{
  return inl ();
}


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

* [Bug middle-end/39333] gcc 4.3.3 miscompiles when -finline-small-functions is used
       [not found] <bug-39333-4@http.gcc.gnu.org/bugzilla/>
                   ` (5 preceding siblings ...)
  2012-06-17 13:18 ` galtgendo at o2 dot pl
@ 2013-01-06  2:20 ` galtgendo at o2 dot pl
  2013-01-06  3:34 ` galtgendo at o2 dot pl
  7 siblings, 0 replies; 33+ messages in thread
From: galtgendo at o2 dot pl @ 2013-01-06  2:20 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #30 from Rafał Mużyło <galtgendo at o2 dot pl> 2013-01-06 02:20:08 UTC ---
While 4.7.2 still has the problem, I've just learnt about PR33763.

Now, while that particular patch doesn't help 4.7.2 - even it it sounds like it
should - removing ' __attribute__ ((__always_inline__))' manually does make the
code compile with '-O1'.

So the question: does that patch not apply to -O1 level or is 'extern inline'
and 'extern __inline' simply not being the same thing ?
If it's the later, would a similar fix be applicable here too ?


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

* [Bug middle-end/39333] gcc 4.3.3 miscompiles when -finline-small-functions is used
       [not found] <bug-39333-4@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2011-09-11 15:08 ` galtgendo at o2 dot pl
@ 2012-06-17 13:18 ` galtgendo at o2 dot pl
  2013-01-06  2:20 ` galtgendo at o2 dot pl
  2013-01-06  3:34 ` galtgendo at o2 dot pl
  7 siblings, 0 replies; 33+ messages in thread
From: galtgendo at o2 dot pl @ 2012-06-17 13:18 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #29 from Rafał Mużyło <galtgendo at o2 dot pl> 2012-06-17 13:17:36 UTC ---
gcc 4.7.1 still shows inconsistent behavior with attachment 25239.


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

* [Bug middle-end/39333] gcc 4.3.3 miscompiles when -finline-small-functions is used
       [not found] <bug-39333-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2011-09-11  9:16 ` galtgendo at o2 dot pl
@ 2011-09-11 15:08 ` galtgendo at o2 dot pl
  2012-06-17 13:18 ` galtgendo at o2 dot pl
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 33+ messages in thread
From: galtgendo at o2 dot pl @ 2011-09-11 15:08 UTC (permalink / raw)
  To: gcc-bugs

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

Rafał Mużyło <galtgendo at o2 dot pl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #25238|0                           |1
        is obsolete|                            |

--- Comment #28 from Rafał Mużyło <galtgendo at o2 dot pl> 2011-09-11 14:55:09 UTC ---
Created attachment 25239
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=25239
previous code, trimmed a bit more

OK, I think that as far, as it can be trimmed.

Now, somebody needs to figure out were things go wrong.


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

* [Bug middle-end/39333] gcc 4.3.3 miscompiles when -finline-small-functions is used
       [not found] <bug-39333-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2011-06-29 13:28 ` dexuan.cui at intel dot com
@ 2011-09-11  9:16 ` galtgendo at o2 dot pl
  2011-09-11 15:08 ` galtgendo at o2 dot pl
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 33+ messages in thread
From: galtgendo at o2 dot pl @ 2011-09-11  9:16 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #27 from Rafał Mużyło <galtgendo at o2 dot pl> 2011-09-11 03:40:16 UTC ---
Created attachment 25238
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=25238
prepocessed code of possibly related failure in gcc 4.6.1

OK, I'm not sure if comments from 24 on have anything to do with the original
problem, but...

https://bugs.gentoo.org/show_bug.cgi?id=365015
There you'll find an interesting testcase, that I've reduced to just this much
preprocessed code - it fails with '-O1', succeeds with '-O2'.

To be exact, it succeeds with '-O1 -fipa-cp'.
What's more, it also succeeds, if '__attribute__ ((__always_inline__))' is
removed.

The exact failure:
Using built-in specs.
COLLECT_GCC=gcc-4.6.1
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/i686-pc-linux-gnu/4.6.1/lto-wrapper
Target: i686-pc-linux-gnu
Configured with:
/mnt/workbox/builds/portage/sys-devel/gcc-4.6.1-r1/work/gcc-4.6.1/configure
--prefix=/usr --bindir=/usr/i686-pc-linux-gnu/gcc-bin/4.6.1
--includedir=/usr/lib/gcc/i686-pc-linux-gnu/4.6.1/include
--datadir=/usr/share/gcc-data/i686-pc-linux-gnu/4.6.1
--mandir=/usr/share/gcc-data/i686-pc-linux-gnu/4.6.1/man
--infodir=/usr/share/gcc-data/i686-pc-linux-gnu/4.6.1/info
--with-gxx-include-dir=/usr/lib/gcc/i686-pc-linux-gnu/4.6.1/include/g++-v4
--host=i686-pc-linux-gnu --build=i686-pc-linux-gnu --disable-altivec
--disable-fixed-point --with-ppl --with-cloog --disable-ppl-version-check
--with-cloog-include=/usr/include/cloog-ppl --enable-lto --enable-nls
--without-included-gettext --with-system-zlib --disable-werror
--enable-secureplt --disable-multilib --enable-libmudflap --disable-libssp
--enable-libgomp
--with-python-dir=/share/gcc-data/i686-pc-linux-gnu/4.6.1/python
--enable-checking=release --disable-libgcj --with-arch=i686 --enable-objc-gc
--enable-languages=c,c++,objc,fortran --enable-shared --enable-threads=posix
--enable-__cxa_atexit --enable-clocale=gnu
--with-bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo 4.6.1-r1 p1.0,
pie-0.4.5' --disable-libstdcxx-pch
Thread model: posix
gcc version 4.6.1 (Gentoo 4.6.1-r1 p1.0, pie-0.4.5) 
COLLECT_GCC_OPTIONS='-v' '-Wall' '-O1' '-c' '-o' 'fprintf-bug0-4.6.o'
'-save-temps' '-mtune=generic' '-march=i686'
 /usr/libexec/gcc/i686-pc-linux-gnu/4.6.1/cc1 -fpreprocessed fprintf-bug0-4.6.i
-quiet -dumpbase fprintf-bug0-4.6.i -mtune=generic -march=i686 -auxbase-strip
fprintf-bug0-4.6.o -O1 -Wall -version -o fprintf-bug0-4.6.s
GNU C (Gentoo 4.6.1-r1 p1.0, pie-0.4.5) version 4.6.1 (i686-pc-linux-gnu)
    compiled by GNU C version 4.6.1, GMP version 5.0.2, MPFR version 3.0.1-p4,
MPC version 0.8.2
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU C (Gentoo 4.6.1-r1 p1.0, pie-0.4.5) version 4.6.1 (i686-pc-linux-gnu)
    compiled by GNU C version 4.6.1, GMP version 5.0.2, MPFR version 3.0.1-p4,
MPC version 0.8.2
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 5f6717c7397ac8a8888626933ce7eb52
fprintf-bug0-4.6.i: In function ‘write_cfg’:
fprintf-bug0-4.6.i:71:1: sorry, unimplemented: inlining failed in call to
‘fprintf’: indirect function call with a yet undetermined callee
fprintf-bug0-4.6.i:78:7: sorry, unimplemented: called from here


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

* [Bug middle-end/39333] gcc 4.3.3 miscompiles when -finline-small-functions is used
       [not found] <bug-39333-4@http.gcc.gnu.org/bugzilla/>
  2011-03-26  8:19 ` dirtyepic at gentoo dot org
  2011-03-26  8:25 ` dirtyepic at gentoo dot org
@ 2011-06-29 13:28 ` dexuan.cui at intel dot com
  2011-09-11  9:16 ` galtgendo at o2 dot pl
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 33+ messages in thread
From: dexuan.cui at intel dot com @ 2011-06-29 13:28 UTC (permalink / raw)
  To: gcc-bugs

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

Dexuan Cui <dexuan.cui at intel dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dexuan.cui at intel dot com

--- Comment #26 from Dexuan Cui <dexuan.cui at intel dot com> 2011-06-29 13:28:32 UTC ---
(In reply to comment #24)
> I'm seeing this exact behaviour with 4.6 (r171422) with grub-0.97. 
> Unfortunately again there is no self-contained test case.
> It appears "stage2" is being miscompiled.  At least, if I copy that file from a
> 4.5 build everything works.
> This is how I can reproduce it:
> - build grub-0.97.  The object files are built like
> gcc -m32 -DHAVE_CONFIG_H -I. -I.. -I../stage1  -Wall -Wmissing-prototypes
> -Wunused -Wshadow -Wpointer-arith -falign-jumps=1 -falign-loops=1
> -falign-functions=1 -Wundef -Os -fno-stack-protector -fno-builtin -nostdinc 
> -DSUPPORT_SERIAL=1 -DSUPPORT_HERCULES=1 -DSUPPORT_GRAPHICS=1 -DFSYS_EXT2FS=1
> -DFSYS_FAT=1 -DFSYS_FFS=1 -DFSYS_UFS2=1 -DFSYS_MINIX=1 -DFSYS_REISERFS=1
> -DFSYS_VSTAFS=1 -DFSYS_JFS=1 -DFSYS_XFS=1 -DFSYS_ISO9660=1
> -DUSE_MD5_PASSWORDS=1 -g -MT pre_stage2_exec-stage2.o -MD -MP -MF
> .deps/pre_stage2_exec-stage2.Tpo -c -o pre_stage2_exec-stage2.o `test -f
> 'stage2.c' || echo './'`stage2.c
> - after installation, run `grub-install /dev/sda`
>  # grub-install /dev/sda
>     GNU GRUB  version 0.97  (640K lower / 9216K upper memory)
>  [ Minimal BASH-like line editing is supported.  For the first word, TAB
>    lists possible command completions.  Anywhere else TAB lists the possible
>    completions of a device/filename. ]
> grub> root (hd0,0)
>  Filesystem type is ext2fs, partition type 0x83
> grub> setup  --stage2=/boot/grub/stage2 --prefix=/grub (hd0)
>  Checking if "/grub/stage1" exists... yes
>  Checking if "/grub/stage2" exists... yes
>  Checking if "/grub/e2fs_stage1_5" exists... yes
>  Running "embed /grub/e2fs_stage1_5 (hd0)"...  24 sectors are embedded.
> succeeded
>  Running "install --stage2=/boot/grub/stage2 /grub/stage1 (hd0) (hd0)1+24 p
> (hd0,0)/grub/stage2 /grub/menu.lst"... failed
> Error 6: Mismatched or corrupt version of stage1/stage2
> grub> quit
> -fno-inline-small-functions works
> -fno-inline-small-functions -finline-functions works
> -fno-guess-branch-probability works
> -fno-ipa-profile works
> -fno-strict-aliasing works with -Os but not -O2
> I understand this is impossible to debug.  I'm just hoping it might spin some
> wheels.  Grub isn't something we like to miscompile. ;) Let me know what other
> info/files would be useful.

In poky we got the same issue:
http://bugzilla.pokylinux.org/show_bug.cgi?id=1099.

Thanks Ryan Hill for the investigation with grub-0.97 and gcc-4.6.

Look forward to a formal fix in gcc...


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

* [Bug middle-end/39333] gcc 4.3.3 miscompiles when -finline-small-functions is used
       [not found] <bug-39333-4@http.gcc.gnu.org/bugzilla/>
  2011-03-26  8:19 ` dirtyepic at gentoo dot org
@ 2011-03-26  8:25 ` dirtyepic at gentoo dot org
  2011-06-29 13:28 ` dexuan.cui at intel dot com
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 33+ messages in thread
From: dirtyepic at gentoo dot org @ 2011-03-26  8:25 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #25 from Ryan Hill <dirtyepic at gentoo dot org> 2011-03-26 08:04:14 UTC ---
-fno-inline-small-functions works with -O2, not -Os.


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

* [Bug middle-end/39333] gcc 4.3.3 miscompiles when -finline-small-functions is used
       [not found] <bug-39333-4@http.gcc.gnu.org/bugzilla/>
@ 2011-03-26  8:19 ` dirtyepic at gentoo dot org
  2011-03-26  8:25 ` dirtyepic at gentoo dot org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 33+ messages in thread
From: dirtyepic at gentoo dot org @ 2011-03-26  8:19 UTC (permalink / raw)
  To: gcc-bugs

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

Ryan Hill <dirtyepic at gentoo dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dirtyepic at gentoo dot org

--- Comment #24 from Ryan Hill <dirtyepic at gentoo dot org> 2011-03-26 07:31:02 UTC ---
I'm seeing this exact behaviour with 4.6 (r171422) with grub-0.97. 
Unfortunately again there is no self-contained test case.

It appears "stage2" is being miscompiled.  At least, if I copy that file from a
4.5 build everything works.

This is how I can reproduce it:

- build grub-0.97.  The object files are built like

gcc -m32 -DHAVE_CONFIG_H -I. -I.. -I../stage1  -Wall -Wmissing-prototypes
-Wunused -Wshadow -Wpointer-arith -falign-jumps=1 -falign-loops=1
-falign-functions=1 -Wundef -Os -fno-stack-protector -fno-builtin -nostdinc 
-DSUPPORT_SERIAL=1 -DSUPPORT_HERCULES=1 -DSUPPORT_GRAPHICS=1 -DFSYS_EXT2FS=1
-DFSYS_FAT=1 -DFSYS_FFS=1 -DFSYS_UFS2=1 -DFSYS_MINIX=1 -DFSYS_REISERFS=1
-DFSYS_VSTAFS=1 -DFSYS_JFS=1 -DFSYS_XFS=1 -DFSYS_ISO9660=1
-DUSE_MD5_PASSWORDS=1 -g -MT pre_stage2_exec-stage2.o -MD -MP -MF
.deps/pre_stage2_exec-stage2.Tpo -c -o pre_stage2_exec-stage2.o `test -f
'stage2.c' || echo './'`stage2.c

- after installation, run `grub-install /dev/sda`

 # grub-install /dev/sda

    GNU GRUB  version 0.97  (640K lower / 9216K upper memory)

 [ Minimal BASH-like line editing is supported.  For the first word, TAB
   lists possible command completions.  Anywhere else TAB lists the possible
   completions of a device/filename. ]
grub> root (hd0,0)
 Filesystem type is ext2fs, partition type 0x83
grub> setup  --stage2=/boot/grub/stage2 --prefix=/grub (hd0)
 Checking if "/grub/stage1" exists... yes
 Checking if "/grub/stage2" exists... yes
 Checking if "/grub/e2fs_stage1_5" exists... yes
 Running "embed /grub/e2fs_stage1_5 (hd0)"...  24 sectors are embedded.
succeeded
 Running "install --stage2=/boot/grub/stage2 /grub/stage1 (hd0) (hd0)1+24 p
(hd0,0)/grub/stage2 /grub/menu.lst"... failed

Error 6: Mismatched or corrupt version of stage1/stage2
grub> quit


-fno-inline-small-functions works
-fno-inline-small-functions -finline-functions works
-fno-guess-branch-probability works
-fno-ipa-profile works
-fno-strict-aliasing works with -Os but not -O2


I understand this is impossible to debug.  I'm just hoping it might spin some
wheels.  Grub isn't something we like to miscompile. ;) Let me know what other
info/files would be useful.


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

end of thread, other threads:[~2013-01-06  3:34 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-01 18:18 [Bug c/39333] New: gcc 4.3.3 miscompiles when -finline-small-functions is used galtgendo at o2 dot pl
2009-03-01 18:20 ` [Bug c/39333] " galtgendo at o2 dot pl
2009-03-02 13:52 ` [Bug middle-end/39333] " pinskia at gcc dot gnu dot org
2009-03-02 21:56 ` galtgendo at o2 dot pl
2009-03-02 22:20 ` galtgendo at o2 dot pl
2009-03-02 22:43 ` pinskia at gcc dot gnu dot org
2009-03-03  0:20 ` galtgendo at o2 dot pl
2009-03-03  0:21 ` pinskia at gcc dot gnu dot org
2009-03-03  3:23 ` galtgendo at o2 dot pl
2009-03-03  3:43 ` galtgendo at o2 dot pl
2009-03-03  3:51 ` pinskia at gcc dot gnu dot org
2009-03-03 15:15 ` galtgendo at o2 dot pl
2009-03-03 16:17 ` galtgendo at o2 dot pl
2009-03-03 16:22 ` galtgendo at o2 dot pl
2009-03-03 17:01 ` hjl dot tools at gmail dot com
2009-03-03 21:13 ` galtgendo at o2 dot pl
2009-03-07  4:30 ` galtgendo at o2 dot pl
2009-03-07  4:35   ` Andrew Thomas Pinski
2009-03-07  4:36 ` pinskia at gmail dot com
2009-03-07 14:06 ` galtgendo at o2 dot pl
2009-03-16 10:24 ` falk at debian dot org
2009-04-22  0:04 ` galtgendo at o2 dot pl
2009-04-22  0:23 ` galtgendo at o2 dot pl
2009-04-22  1:08 ` galtgendo at o2 dot pl
2009-04-22  1:15 ` galtgendo at o2 dot pl
     [not found] <bug-39333-4@http.gcc.gnu.org/bugzilla/>
2011-03-26  8:19 ` dirtyepic at gentoo dot org
2011-03-26  8:25 ` dirtyepic at gentoo dot org
2011-06-29 13:28 ` dexuan.cui at intel dot com
2011-09-11  9:16 ` galtgendo at o2 dot pl
2011-09-11 15:08 ` galtgendo at o2 dot pl
2012-06-17 13:18 ` galtgendo at o2 dot pl
2013-01-06  2:20 ` galtgendo at o2 dot pl
2013-01-06  3:34 ` galtgendo at o2 dot pl

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