This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/30139] overflow warning for unevaluated part of expression



------- Comment #2 from manu at gcc dot gnu dot org  2006-12-11 19:35 -------
(In reply to comment #1)
> I think the C front-end is incorrect in not warning, though someone has to look
> into the standard to be sure.
> 

Is there a searchable version of the standard?

Anyway, the following code snippet from Joseph Myers at
testsuite/gcc.dg/overflow-warn-1.c seems to imply otherwise:

enum e {
   /* Overflow in an unevaluated part of an expression is OK (example
     in the standard).  */
  E2 = 2 || 1 / 0
};


/* The first two of these involve overflow, so are not null pointer
   constants.  The third has the overflow in an unevaluated
   subexpression, so is a null pointer constant.  */
void *p = 0 * (INT_MAX + 1); /* { dg-warning "warning: integer overflow in
expression" } */
/* { dg-warning "warning: initialization makes pointer from integer without a
cast" "null" { target *-*-* } 48 } */
void *q = 0 * (1 / 0); /* { dg-warning "warning: division by zero" } */
/* { dg-warning "warning: initialization makes pointer from integer without a
cast" "null" { xfail *-*-* } 50 } */
void *r = (1 ? 0 : INT_MAX+1);


-- 


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]