public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/51151] New: Invalid -Woverflow warning in C++ frontend
@ 2011-11-16  6:15 ian at airs dot com
  2011-11-17  1:44 ` [Bug c++/51151] " ian at airs dot com
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: ian at airs dot com @ 2011-11-16  6:15 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 51151
           Summary: Invalid -Woverflow warning in C++ frontend
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: ian@airs.com


Compile this C++ file with -Wall or -Woverflow:

template<typename T> class C {
public:
  void f() {
    m = c2 + 1;
  }
  static const long unsigned int c1 = 7;
  static const int c2 = c1 - 1;
  int m;
};
template class C<int>;

When I compile this with current mainline, I get:

foo.cc: In instantiation of ‘void C<T>::f() [with T = int]’:
foo.cc:10:16:   required from here
foo.cc:4:5: warning: integer overflow in expression [-Woverflow]

This warning is invalid.  There is no integer overflow here.

From a quick look, it appears that fold winds up being called with
    ((int) ((unsigned int) 7 + 4294967295U)) + 1
It decides to distribute the addition, groups the constants 4294967295 and 1
together, and gets an overflow when it adds them.  At that point it is adding
together an unsigned and a signed constant, having decided to strip the type
conversion as a nop.

This does not happen when not using a template.


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

* [Bug c++/51151] Invalid -Woverflow warning in C++ frontend
  2011-11-16  6:15 [Bug c++/51151] New: Invalid -Woverflow warning in C++ frontend ian at airs dot com
@ 2011-11-17  1:44 ` ian at airs dot com
  2011-12-09 20:52 ` jason at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: ian at airs dot com @ 2011-11-17  1:44 UTC (permalink / raw)
  To: gcc-bugs

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

Ian Lance Taylor <ian at airs dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org

--- Comment #1 from Ian Lance Taylor <ian at airs dot com> 2011-11-17 00:49:39 UTC ---
Appears to have been introduced by this change:

2011-10-11  Jason Merrill  <jason@redhat.com>

    PR c++/49855
    PR c++/49896


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

* [Bug c++/51151] Invalid -Woverflow warning in C++ frontend
  2011-11-16  6:15 [Bug c++/51151] New: Invalid -Woverflow warning in C++ frontend ian at airs dot com
  2011-11-17  1:44 ` [Bug c++/51151] " ian at airs dot com
@ 2011-12-09 20:52 ` jason at gcc dot gnu.org
  2011-12-14 12:03 ` krebbel at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jason at gcc dot gnu.org @ 2011-12-09 20:52 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jason Merrill <jason at gcc dot gnu.org> 2011-12-09 20:18:31 UTC ---
Author: jason
Date: Fri Dec  9 20:18:22 2011
New Revision: 182175

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=182175
Log:
    PR c++/51151
    * call.c (perform_implicit_conversion_flags): Remove earlier kludge.
    * parser.c (cp_parser_omp_for_loop): Use cp_parser_omp_for_incr
    in templates even if decl isn't type-dependent.

Added:
    trunk/gcc/testsuite/g++.dg/warn/Woverflow-4.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/call.c
    trunk/gcc/cp/parser.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug c++/51151] Invalid -Woverflow warning in C++ frontend
  2011-11-16  6:15 [Bug c++/51151] New: Invalid -Woverflow warning in C++ frontend ian at airs dot com
  2011-11-17  1:44 ` [Bug c++/51151] " ian at airs dot com
  2011-12-09 20:52 ` jason at gcc dot gnu.org
@ 2011-12-14 12:03 ` krebbel at gcc dot gnu.org
  2011-12-14 12:11 ` krebbel at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: krebbel at gcc dot gnu.org @ 2011-12-14 12:03 UTC (permalink / raw)
  To: gcc-bugs

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

Andreas Krebbel <krebbel at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |krebbel at gcc dot gnu.org

--- Comment #3 from Andreas Krebbel <krebbel at gcc dot gnu.org> 2011-12-14 12:00:55 UTC ---
r182175 fixed one failure on s390x but introduced a couple of new fails:

< FAIL: libgomp.c/atomic-2.c execution test
---
> FAIL: libgomp.c++/for-2.C  -O0  (test for excess errors)
> WARNING: libgomp.c++/for-2.C  -O0  compilation failed to produce executable
> FAIL: libgomp.c++/for-2.C  -O1  (test for excess errors)
> WARNING: libgomp.c++/for-2.C  -O1  compilation failed to produce executable
> FAIL: libgomp.c++/for-2.C  -O2  (test for excess errors)
> WARNING: libgomp.c++/for-2.C  -O2  compilation failed to produce executable
> FAIL: libgomp.c++/for-2.C  -O3 -fomit-frame-pointer  (test for excess errors)
> WARNING: libgomp.c++/for-2.C  -O3 -fomit-frame-pointer  compilation failed to produce executable
> FAIL: libgomp.c++/for-2.C  -O3 -fomit-frame-pointer -funroll-loops  (test for excess errors)
> WARNING: libgomp.c++/for-2.C  -O3 -fomit-frame-pointer -funroll-loops  compilation failed to produce executable
> FAIL: libgomp.c++/for-2.C  -O3 -fomit-frame-pointer -funroll-all-loops -finline-functions  (test for excess errors)
> WARNING: libgomp.c++/for-2.C  -O3 -fomit-frame-pointer -funroll-all-loops -finline-functions  compilation failed to produce executable
> FAIL: libgomp.c++/for-2.C  -O3 -g  (test for excess errors)
> WARNING: libgomp.c++/for-2.C  -O3 -g  compilation failed to produce executable
> FAIL: libgomp.c++/for-2.C  -Os  (test for excess errors)
> WARNING: libgomp.c++/for-2.C  -Os  compilation failed to produce executable


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

* [Bug c++/51151] Invalid -Woverflow warning in C++ frontend
  2011-11-16  6:15 [Bug c++/51151] New: Invalid -Woverflow warning in C++ frontend ian at airs dot com
                   ` (2 preceding siblings ...)
  2011-12-14 12:03 ` krebbel at gcc dot gnu.org
@ 2011-12-14 12:11 ` krebbel at gcc dot gnu.org
  2011-12-14 14:33 ` dominiq at lps dot ens.fr
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: krebbel at gcc dot gnu.org @ 2011-12-14 12:11 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Andreas Krebbel <krebbel at gcc dot gnu.org> 2011-12-14 12:02:47 UTC ---
libgomp/testsuite/libgomp.c++/for-2.C: In function 'void f7(int, int, int)':^M
libgomp/testsuite/libgomp.c++/for-2.C:87:3: error: invalid increment
expression^M
compiler exited with status 1
output is:
libgomp/testsuite/libgomp.c++/for-2.C: In function 'void f7(int, int, int)':^M
libgomp/testsuite/libgomp.c++/for-2.C:87:3: error: invalid increment
expression^M

FAIL: libgomp.c++/for-2.C  -O0  (test for excess errors)
Excess errors:
libgomp/testsuite/libgomp.c++/for-2.C:87:3: error: invalid increment expression

WARNING: libgomp.c++/for-2.C  -O0  compilation failed to produce executable


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

* [Bug c++/51151] Invalid -Woverflow warning in C++ frontend
  2011-11-16  6:15 [Bug c++/51151] New: Invalid -Woverflow warning in C++ frontend ian at airs dot com
                   ` (3 preceding siblings ...)
  2011-12-14 12:11 ` krebbel at gcc dot gnu.org
@ 2011-12-14 14:33 ` dominiq at lps dot ens.fr
  2012-01-02 17:35 ` aaw at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: dominiq at lps dot ens.fr @ 2011-12-14 14:33 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Dominique d'Humieres <dominiq at lps dot ens.fr> 2011-12-14 13:05:35 UTC ---
> r182175 fixed one failure on s390x but introduced a couple of new fails:
>
> < FAIL: libgomp.c/atomic-2.c execution test
> ---
> > FAIL: libgomp.c++/for-2.C  -O0  (test for excess errors)
> > ...

It looks like pr51496 fixed by revision 182257.


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

* [Bug c++/51151] Invalid -Woverflow warning in C++ frontend
  2011-11-16  6:15 [Bug c++/51151] New: Invalid -Woverflow warning in C++ frontend ian at airs dot com
                   ` (4 preceding siblings ...)
  2011-12-14 14:33 ` dominiq at lps dot ens.fr
@ 2012-01-02 17:35 ` aaw at gcc dot gnu.org
  2012-01-02 17:35 ` paolo.carlini at oracle dot com
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: aaw at gcc dot gnu.org @ 2012-01-02 17:35 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Ollie Wild <aaw at gcc dot gnu.org> 2012-01-02 17:35:07 UTC ---
I'm on vacation until Jan. 6.

For compiler related questions, please email c-compiler-team@google.com.

If you need to contact a manager, please email lp-mgrs@google.com.

Thanks,
Ollie


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

* [Bug c++/51151] Invalid -Woverflow warning in C++ frontend
  2011-11-16  6:15 [Bug c++/51151] New: Invalid -Woverflow warning in C++ frontend ian at airs dot com
                   ` (5 preceding siblings ...)
  2012-01-02 17:35 ` aaw at gcc dot gnu.org
@ 2012-01-02 17:35 ` paolo.carlini at oracle dot com
  2012-01-03  8:36 ` krebbel at gcc dot gnu.org
  2012-01-03  8:37 ` krebbel at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-01-02 17:35 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-01-02 17:34:19 UTC ---
Andreas, can we close this?


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

* [Bug c++/51151] Invalid -Woverflow warning in C++ frontend
  2011-11-16  6:15 [Bug c++/51151] New: Invalid -Woverflow warning in C++ frontend ian at airs dot com
                   ` (6 preceding siblings ...)
  2012-01-02 17:35 ` paolo.carlini at oracle dot com
@ 2012-01-03  8:36 ` krebbel at gcc dot gnu.org
  2012-01-03  8:37 ` krebbel at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: krebbel at gcc dot gnu.org @ 2012-01-03  8:36 UTC (permalink / raw)
  To: gcc-bugs

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

Andreas Krebbel <krebbel at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED

--- Comment #8 from Andreas Krebbel <krebbel at gcc dot gnu.org> 2012-01-03 08:35:07 UTC ---
The failures on s390 are fixed (comment #5).


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

* [Bug c++/51151] Invalid -Woverflow warning in C++ frontend
  2011-11-16  6:15 [Bug c++/51151] New: Invalid -Woverflow warning in C++ frontend ian at airs dot com
                   ` (7 preceding siblings ...)
  2012-01-03  8:36 ` krebbel at gcc dot gnu.org
@ 2012-01-03  8:37 ` krebbel at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: krebbel at gcc dot gnu.org @ 2012-01-03  8:37 UTC (permalink / raw)
  To: gcc-bugs

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

Andreas Krebbel <krebbel at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |CLOSED

--- Comment #9 from Andreas Krebbel <krebbel at gcc dot gnu.org> 2012-01-03 08:36:31 UTC ---
Close per comment above.


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

end of thread, other threads:[~2012-01-03  8:37 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-16  6:15 [Bug c++/51151] New: Invalid -Woverflow warning in C++ frontend ian at airs dot com
2011-11-17  1:44 ` [Bug c++/51151] " ian at airs dot com
2011-12-09 20:52 ` jason at gcc dot gnu.org
2011-12-14 12:03 ` krebbel at gcc dot gnu.org
2011-12-14 12:11 ` krebbel at gcc dot gnu.org
2011-12-14 14:33 ` dominiq at lps dot ens.fr
2012-01-02 17:35 ` aaw at gcc dot gnu.org
2012-01-02 17:35 ` paolo.carlini at oracle dot com
2012-01-03  8:36 ` krebbel at gcc dot gnu.org
2012-01-03  8:37 ` krebbel at gcc dot gnu.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).