[Bug other/56579] New: 4.8.0-20130303 g++ optimisation flags cause segfault or different program output

2013-03-09 Thread dacrick at gmail dot com


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



 Bug #: 56579

   Summary: 4.8.0-20130303 g++ optimisation flags cause segfault

or different program output

Classification: Unclassified

   Product: gcc

   Version: 4.8.0

Status: UNCONFIRMED

  Severity: normal

  Priority: P3

 Component: other

AssignedTo: unassig...@gcc.gnu.org

ReportedBy: dacr...@gmail.com





Created attachment 29627

  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29627

preprocessed version of paq8kx compression program source code



[My first GCC bug report so please kindly point out what

further information you may need.  I have tried to adhere

to the instructions at http://gcc.gnu.org/bugs/  Thanks.]



output of g++ -v:



Using built-in specs.

COLLECT_GCC=/usr/local/gcc-4.8-20130303/bin/g++

COLLECT_LTO_WRAPPER=/usr/local/gcc-4.8-20130303/libexec/gcc/x86_64-unknown-linux-gnu/4.8.0/lto-wrapper

Target: x86_64-unknown-linux-gnu

Configured with: ./configure --prefix=/usr/local/gcc-4.8-20130303

Thread model: posix

gcc version 4.8.0 20130303 (experimental) (GCC)





Running the compiled program ("./paq8kx somefile") when

compiled with -O3 or -Ofast results in a segfault.



Running when compiled with -O2 no longer segfaults but

produces different program output than expected.



-O1 segfaults



-O0 and Og run and create expected output.



(Note that the above -Ox behaviour is independent of

other compiler flags (including but not limited to -flto),

and can be achieved merely by using -Ox as the sole

differentiator.)





This compares to GCC 4.7.2 and my distro provided

4.4.6, which both produce binaries that do not segfault

at all and also generate identical program output

irrespective of -O option chosen at compile time.

Running the program author's pre-compiled binary

likewise matches 4.7.2 and 4.4.6 behaviour and output.





This is the only program that I've compiled using GCC

4.8 that does not run as expected; all others run fine.



It therefore appears that 4.8.0's optimizer is being

tripped up by something in paq8kx.


[Bug other/56579] 4.8.0-20130303 g++ optimisation flags cause segfault or different program output

2013-03-09 Thread dacrick at gmail dot com


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



dacrick at gmail dot com changed:



   What|Removed |Added



 CC||dacrick at gmail dot com



--- Comment #1 from dacrick at gmail dot com 2013-03-09 16:12:34 UTC ---

Something in the back of my mind has since reminded

me of -fno-aggressive-loop-optimizations, and compiling

at (e.g.) -O3 using -fno-aggressive-loop-optimizations

no longer segfaults and produces the expected output.


[Bug other/56579] 4.8.0-20130303 g++ optimisation flags cause segfault or different program output

2013-03-09 Thread dacrick at gmail dot com


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



--- Comment #3 from dacrick at gmail dot com 2013-03-09 16:48:40 UTC ---

(In reply to comment #2)

> That most likely means that the programm is invoking undefined

> behaviour and thus invalid.

> 

> A quick check with "clang++ -fsanitize=undefined" confirms this:

> ...

>  paq8kx_v7.cpp:1795:13: fatal error: signed integer overflow: 707863021 * 8

> cannot be represented in type 'int'



Thanks for your further investigation.



Clearly an error in the program code then.



Shall I change status of bug to RESOLVED? (assuming that's

how I close the bug?)


[Bug other/56579] 4.8.0-20130303 g++ optimisation flags cause segfault or different program output

2013-03-09 Thread dacrick at gmail dot com


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



dacrick at gmail dot com changed:



   What|Removed |Added



 Status|UNCONFIRMED |RESOLVED

 Resolution||INVALID



--- Comment #5 from dacrick at gmail dot com 2013-03-09 16:55:12 UTC ---

(In reply to comment #4)

> Yes, RESOLVED->INVALID.



many thanks.



Apologies for the false alarm / "noise", and thank you

again for your help and further diagnosis.