public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/28986]  New: Failure to diagnose overflow in constant expression
@ 2006-09-08 18:39 amylaar at gcc dot gnu dot org
  2006-09-09  4:14 ` [Bug c++/28986] " pinskia at gcc dot gnu dot org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: amylaar at gcc dot gnu dot org @ 2006-09-08 18:39 UTC (permalink / raw)
  To: gcc-bugs

g++ doesn't diagnose the overflow (clause 5 paragraph 5) in the following
constant expression:

#include <limits.h>

long l = LONG_MAX+1;


-- 
           Summary: Failure to diagnose overflow in constant expression
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Keywords: accepts-invalid
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: amylaar at gcc dot gnu dot org


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


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

* [Bug c++/28986] Failure to diagnose overflow in constant expression
  2006-09-08 18:39 [Bug c++/28986] New: Failure to diagnose overflow in constant expression amylaar at gcc dot gnu dot org
@ 2006-09-09  4:14 ` pinskia at gcc dot gnu dot org
  2006-11-25 14:07 ` manu at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-09-09  4:14 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2006-09-09 04:14 -------
Confirmed, not a regression and only happens with the C++ front-end.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
      Known to fail|                            |2.95 3.2.3 3.3.3 3.4.0 4.0.0
                   |                            |4.1.0 4.2.0
   Last reconfirmed|0000-00-00 00:00:00         |2006-09-09 04:14:01
               date|                            |


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


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

* [Bug c++/28986] Failure to diagnose overflow in constant expression
  2006-09-08 18:39 [Bug c++/28986] New: Failure to diagnose overflow in constant expression amylaar at gcc dot gnu dot org
  2006-09-09  4:14 ` [Bug c++/28986] " pinskia at gcc dot gnu dot org
@ 2006-11-25 14:07 ` manu at gcc dot gnu dot org
  2006-11-28 22:35 ` manu at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: manu at gcc dot gnu dot org @ 2006-11-25 14:07 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from manu at gcc dot gnu dot org  2006-11-25 14:06 -------
As far as I can see, the C++ front-end fails to call overflow_warning
(c-common.c) from build_binary_op (cp/typeck.c) in the same way as the C
front-end does in parser_build_binary_op(c-typeck.c).


-- 

manu at gcc dot gnu dot org changed:

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


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


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

* [Bug c++/28986] Failure to diagnose overflow in constant expression
  2006-09-08 18:39 [Bug c++/28986] New: Failure to diagnose overflow in constant expression amylaar at gcc dot gnu dot org
  2006-09-09  4:14 ` [Bug c++/28986] " pinskia at gcc dot gnu dot org
  2006-11-25 14:07 ` manu at gcc dot gnu dot org
@ 2006-11-28 22:35 ` manu at gcc dot gnu dot org
  2006-12-01 23:36 ` manu at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: manu at gcc dot gnu dot org @ 2006-11-28 22:35 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from manu at gcc dot gnu dot org  2006-11-28 22:35 -------
Roger,

The patch below fixes this bug. But it also introduces bug 19978 (multiple
warnings) in the C++ front-end. Yet, all regression testcases pass. They pass
because C++ overflow testcases are very limited and because the testsuite
cannot detect that the same warning has been emitted two times at the same
line. (Anyway to workaround the latter? How can we detect in the testcase below
that there are two "integer overflow in expression" and put a XFAIL to one of
them?) 

What do you think of this? 


Index: gcc/testsuite/g++.dg/conversion/nullptr1.C
===================================================================
--- gcc/testsuite/g++.dg/conversion/nullptr1.C  (revision 119259)
+++ gcc/testsuite/g++.dg/conversion/nullptr1.C  (working copy)
@@ -6,5 +6,5 @@
 void *p = 0;

 void *q = 0 * (INT_MAX + 1);  // { dg-error "invalid conversion" }
+// { dg-warning "integer overflow in expression" "" { target *-*-* } 8 }

-
Index: gcc/cp/typeck.c
===================================================================
--- gcc/cp/typeck.c     (revision 119259)
+++ gcc/cp/typeck.c     (working copy)
@@ -3719,6 +3719,9 @@
   result = fold_if_not_in_template (result);
   if (final_type != 0)
     result = cp_convert (final_type, result);
+
+  overflow_warning (result);
+
   return result;
 }
 ^L


-- 

manu at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |roger at eyesopen dot com


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


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

* [Bug c++/28986] Failure to diagnose overflow in constant expression
  2006-09-08 18:39 [Bug c++/28986] New: Failure to diagnose overflow in constant expression amylaar at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2006-11-28 22:35 ` manu at gcc dot gnu dot org
@ 2006-12-01 23:36 ` manu at gcc dot gnu dot org
  2006-12-09 21:51 ` manu at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: manu at gcc dot gnu dot org @ 2006-12-01 23:36 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from manu at gcc dot gnu dot org  2006-12-01 23:36 -------
I am working in a patch but don't expect it too soon. Yet, I am quite advanced,
that is why I am accepting it. If this is not the proper way to do it, please
let me know.


-- 

manu at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |manu at gcc dot gnu dot org
                   |dot org                     |
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2006-09-09 04:14:01         |2006-12-01 23:36:32
               date|                            |


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


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

* [Bug c++/28986] Failure to diagnose overflow in constant expression
  2006-09-08 18:39 [Bug c++/28986] New: Failure to diagnose overflow in constant expression amylaar at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2006-12-01 23:36 ` manu at gcc dot gnu dot org
@ 2006-12-09 21:51 ` manu at gcc dot gnu dot org
  2007-01-02 14:04 ` andrew dot stubbs at st dot com
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: manu at gcc dot gnu dot org @ 2006-12-09 21:51 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from manu at gcc dot gnu dot org  2006-12-09 21:51 -------
Why is this "accepts-invalid"? Shouldn't it be "diagnostic" instead? I am
trying to understand what is the expected output here: a warning or a pedantic
error? 


-- 

manu at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|2006-12-01 23:36:32         |2006-12-09 21:51:31
               date|                            |


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


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

* [Bug c++/28986] Failure to diagnose overflow in constant expression
  2006-09-08 18:39 [Bug c++/28986] New: Failure to diagnose overflow in constant expression amylaar at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2006-12-09 21:51 ` manu at gcc dot gnu dot org
@ 2007-01-02 14:04 ` andrew dot stubbs at st dot com
  2007-01-02 23:33 ` gdr at integrable-solutions dot net
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: andrew dot stubbs at st dot com @ 2007-01-02 14:04 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from andrew dot stubbs at st dot com  2007-01-02 14:04 -------
(In reply to comment #5)
> Why is this "accepts-invalid"? Shouldn't it be "diagnostic" instead? I am
> trying to understand what is the expected output here: a warning or a pedantic
> error? 

Clause 5 paragraph 5 says it is "ill-formed". Therefore accepts-invalid sounds
right to me.

In pedantic mode this should definitely be an error in my opinion. What it
should do otherwise is not clear to me. It seems sensible to accept it with
-fpermissive.


-- 


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


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

* [Bug c++/28986] Failure to diagnose overflow in constant expression
  2006-09-08 18:39 [Bug c++/28986] New: Failure to diagnose overflow in constant expression amylaar at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2007-01-02 14:04 ` andrew dot stubbs at st dot com
@ 2007-01-02 23:33 ` gdr at integrable-solutions dot net
  2007-01-06 17:50 ` patchapp at dberlin dot org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: gdr at integrable-solutions dot net @ 2007-01-02 23:33 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from gdr at integrable-solutions dot net  2007-01-02 23:33 -------
Subject: Re:  Failure to diagnose overflow in constant expression

"andrew dot stubbs at st dot com" <gcc-bugzilla@gcc.gnu.org> writes:

| ------- Comment #6 from andrew dot stubbs at st dot com  2007-01-02 14:04
-------
| (In reply to comment #5)
| > Why is this "accepts-invalid"? Shouldn't it be "diagnostic" instead? I am
| > trying to understand what is the expected output here: a warning or a
pedantic
| > error? 
| 
| Clause 5 paragraph 5 says it is "ill-formed". Therefore accepts-invalid
sounds
| right to me.

In C++, "ill-formed" implies "diagnostic is required" unless
explicitly noted otherwise. 

-- Gaby


-- 


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


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

* [Bug c++/28986] Failure to diagnose overflow in constant expression
  2006-09-08 18:39 [Bug c++/28986] New: Failure to diagnose overflow in constant expression amylaar at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  2007-01-02 23:33 ` gdr at integrable-solutions dot net
@ 2007-01-06 17:50 ` patchapp at dberlin dot org
  2007-01-07 23:40 ` manu at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: patchapp at dberlin dot org @ 2007-01-06 17:50 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from patchapp at dberlin dot org  2007-01-06 17:50 -------
Subject: Bug number PR c++/28986

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is
http://gcc.gnu.org/ml/gcc-patches/2007-01/msg00473.html


-- 


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


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

* [Bug c++/28986] Failure to diagnose overflow in constant expression
  2006-09-08 18:39 [Bug c++/28986] New: Failure to diagnose overflow in constant expression amylaar at gcc dot gnu dot org
                   ` (7 preceding siblings ...)
  2007-01-06 17:50 ` patchapp at dberlin dot org
@ 2007-01-07 23:40 ` manu at gcc dot gnu dot org
  2007-01-09 16:03 ` manu at gcc dot gnu dot org
  2007-01-10 18:56 ` pinskia at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: manu at gcc dot gnu dot org @ 2007-01-07 23:40 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from manu at gcc dot gnu dot org  2007-01-07 23:40 -------
Subject: Bug 28986

Author: manu
Date: Sun Jan  7 23:39:55 2007
New Revision: 120558

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=120558
Log:
2007-01-07  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>

        PR c++/28986
cp/
        * typeck.c (build_binary_op): Call overflow_warning if
        TREE_OVERFLOW_P is true for the result and not for any of the
        operands.

testsuite/
        * g++.dg/conversion/nullptr1.C: Added overflow warning.
        * g++.dg/warn/overflow-warn-1.C: New.
        * g++.dg/warn/overflow-warn-3.C: New.
        * g++.dg/warn/overflow-warn-4.C: New.
        * g++.dg/warn/overflow-warn-5.C: New.
        * g++.dg/warn/overflow-warn-6.C: New.
        * g++.dg/warn/Woverflow-1.C: New.
        * g++.dg/warn/Woverflow-2.C: New.
        * g++.dg/warn/Woverflow-3.C: New.
        * g++.dg/warn/multiple-overflow-warn-2.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/warn/Woverflow-1.C
    trunk/gcc/testsuite/g++.dg/warn/Woverflow-2.C
    trunk/gcc/testsuite/g++.dg/warn/Woverflow-3.C
    trunk/gcc/testsuite/g++.dg/warn/multiple-overflow-warn-2.C
    trunk/gcc/testsuite/g++.dg/warn/overflow-warn-1.C
    trunk/gcc/testsuite/g++.dg/warn/overflow-warn-3.C
    trunk/gcc/testsuite/g++.dg/warn/overflow-warn-4.C
    trunk/gcc/testsuite/g++.dg/warn/overflow-warn-5.C
    trunk/gcc/testsuite/g++.dg/warn/overflow-warn-6.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/typeck.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/g++.dg/conversion/nullptr1.C


-- 


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


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

* [Bug c++/28986] Failure to diagnose overflow in constant expression
  2006-09-08 18:39 [Bug c++/28986] New: Failure to diagnose overflow in constant expression amylaar at gcc dot gnu dot org
                   ` (8 preceding siblings ...)
  2007-01-07 23:40 ` manu at gcc dot gnu dot org
@ 2007-01-09 16:03 ` manu at gcc dot gnu dot org
  2007-01-10 18:56 ` pinskia at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: manu at gcc dot gnu dot org @ 2007-01-09 16:03 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from manu at gcc dot gnu dot org  2007-01-09 16:03 -------
Fixed in GCC 4.3


-- 

manu at gcc dot gnu dot org changed:

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


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


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

* [Bug c++/28986] Failure to diagnose overflow in constant expression
  2006-09-08 18:39 [Bug c++/28986] New: Failure to diagnose overflow in constant expression amylaar at gcc dot gnu dot org
                   ` (9 preceding siblings ...)
  2007-01-09 16:03 ` manu at gcc dot gnu dot org
@ 2007-01-10 18:56 ` pinskia at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-01-10 18:56 UTC (permalink / raw)
  To: gcc-bugs



-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.3.0


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


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

end of thread, other threads:[~2007-01-10 18:56 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-09-08 18:39 [Bug c++/28986] New: Failure to diagnose overflow in constant expression amylaar at gcc dot gnu dot org
2006-09-09  4:14 ` [Bug c++/28986] " pinskia at gcc dot gnu dot org
2006-11-25 14:07 ` manu at gcc dot gnu dot org
2006-11-28 22:35 ` manu at gcc dot gnu dot org
2006-12-01 23:36 ` manu at gcc dot gnu dot org
2006-12-09 21:51 ` manu at gcc dot gnu dot org
2007-01-02 14:04 ` andrew dot stubbs at st dot com
2007-01-02 23:33 ` gdr at integrable-solutions dot net
2007-01-06 17:50 ` patchapp at dberlin dot org
2007-01-07 23:40 ` manu at gcc dot gnu dot org
2007-01-09 16:03 ` manu at gcc dot gnu dot org
2007-01-10 18:56 ` pinskia at gcc dot gnu dot 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).