Bug 35581 - Option '-ftree-vrp' looks broken with '-O2'
Summary: Option '-ftree-vrp' looks broken with '-O2'
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 4.3.0
: P3 major
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-03-14 11:56 UTC by Dmitry Antipov
Modified: 2008-03-14 14:26 UTC (History)
2 users (show)

See Also:
Host: x86_64-redhat-linux
Target: x86_64-redhat-linux
Build: x86_64-redhat-linux
Known to work:
Known to fail:
Last reconfirmed:


Attachments
mktime() test from configure (1.65 KB, text/plain)
2008-03-14 11:57 UTC, Dmitry Antipov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dmitry Antipov 2008-03-14 11:56:26 UTC
Attached program is mktime() test usually runs by configure scripts. This test behaves badly (terminates with SIGALRM) if compiled with '-O2', but works as expected when compiled with '-O2 -fno-tree-vrp'.

I'm able to reproduce it on two systems:

1) x86_64 Fedora 8, kernel is 2.6.24.3, gcc 4.3 configured as:
Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-cpu=generic --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.3.0 20080307 (Red Hat 4.3.0-2) (GCC) 

2) i386 FreeBSD 7.0 (7.0-STABLE), gcc 4.3 configured with:
Using built-in specs.
Target: i386-unknown-freebsd7.0
Configured with: ../gcc-4.3.0/configure --program-suffix=43 --prefix=/usr/local --enable-checking=none --enable-multilib --enable-__cxa_atexit --enable-threads=posix --enable-languages=c,c++ --disable-nls --with-cpu=pentium4 --with-system-zlib
Thread model: posix
gcc version 4.3.0 (GCC)
Comment 1 Dmitry Antipov 2008-03-14 11:57:37 UTC
Created attachment 15314 [details]
mktime() test from configure
Comment 2 Andrew Pinski 2008-03-14 12:01:40 UTC
The test has undefined behavior in it as signed integer overflow is undefined.  time_t is a signed integer.
Comment 3 Dmitry Antipov 2008-03-14 13:36:17 UTC
(In reply to comment #2)

> The test has undefined behavior in it as signed integer overflow is undefined. 
> time_t is a signed integer.

Ok, I'll contact autoconf authors with this issue.

BTW, what about issuing the warning like

[file][line]: warning: operation on [whatever] may be undefined

just like in the classic case 

i = ++i + ++i;

?

Comment 4 Ralf Wildenhues 2008-03-14 13:50:31 UTC
(In reply to comment #3)
> Ok, I'll contact autoconf authors with this issue.

That's pretty funny that you encounter this AC_FUNC_MKTIME bug now which
when I encountered it asked about it on the GCC list and which caused this
gigantic thread (and sometime later the overflow warnings were implemented,
see <http://gcc.gnu.org/gcc-4.2/changes.html> for a high-level description).

Anyway, here's the thread and also the patch that fixed this in Autoconf
(unfortunately, you still have to wait for the next stable release :-(
<http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/8152/focus=8281>
Comment 5 Dmitry Antipov 2008-03-14 14:26:09 UTC
OK, I've found -[Wf]strict-overflow. Sorry for the dumb question.

But, why not enable -Wstrict-overflow=[2345] by default when -Wextra is specified?