public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/17880] New: -Wsequence-point doesn't warn inside if, while, do conditions, for beg/cond/end expressions etc.
@ 2004-10-07  9:52 jakub at gcc dot gnu dot org
  2004-10-07 10:09 ` [Bug c/17880] " giovannibajo at libero dot it
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: jakub at gcc dot gnu dot org @ 2004-10-07  9:52 UTC (permalink / raw)
  To: gcc-bugs

/* { dg-do compile } */
/* { dg-options "-Wsequence-point" } */

int
foo (int x)
{
  unsigned int a = x;
  int b;
  b = (a += 5) > a;  /* { dg-warning "undefined" "sequence point warning" } */
  b = (a += 5) + a == 10;  /* { dg-warning "undefined" "sequence point warning" }
*/
  b = (a -= 5) > a;  /* { dg-warning "undefined" "sequence point warning" } */
  b = (a -= 5) + a == 10;  /* { dg-warning "undefined" "sequence point warning" }
*/
  b = a-- > a;  /* { dg-warning "undefined" "sequence point warning" } */
  b = a-- + a == 10;  /* { dg-warning "undefined" "sequence point warning" } */
  b = ++a > a;  /* { dg-warning "undefined" "sequence point warning" } */
  b = ++a + a == 10;  /* { dg-warning "undefined" "sequence point warning" } */
  if ((a += 5) > a) return -1;  /* { dg-warning "undefined" "sequence point
warning" } */
  if ((a += 5) + a == 10) return -1;  /* { dg-warning "undefined" "sequence point
warning" } */
  if ((a -= 5) > a) return -1;  /* { dg-warning "undefined" "sequence point
warning" } */
  if ((a -= 5) + a == 10) return -1;  /* { dg-warning "undefined" "sequence point
warning" } */
  if (a-- > a) return -1;  /* { dg-warning "undefined" "sequence point warning" }
*/
  if (a-- + a == 10) return -1;  /* { dg-warning "undefined" "sequence point
warning" } */
  if (++a > a) return -1;  /* { dg-warning "undefined" "sequence point warning" }
*/
  if (++a + a == 10) return -1;  /* { dg-warning "undefined" "sequence point
warning" } */
  do {} while ((a += 5) > a);  /* { dg-warning "undefined" "sequence point
warning" } */
  while ((a += 5) > a);  /* { dg-warning "undefined" "sequence point warning" }
*/
  for (b = (a += 5) > a;;);  /* { dg-warning "undefined" "sequence point warning"
} */
  for (; (a += 5) > a;);  /* { dg-warning "undefined" "sequence point warning" }
*/
  for (;; b = (a += 5) > a);  /* { dg-warning "undefined" "sequence point
warning" } */
  return 0;
}

While it is certainly possible to call verify_sequence_points for each condition
etc. from c-parse.in and parse.y, I think much better would be to move this
warning to say c_genericize, walk over all statements and call
verify_sequence_points where needed.

-- 
           Summary: -Wsequence-point doesn't warn inside if, while, do
                    conditions, for beg/cond/end expressions etc.
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jakub at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org,jsm at polyomino dot org
                    dot uk


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


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

* [Bug c/17880] -Wsequence-point doesn't warn inside if, while, do conditions, for beg/cond/end expressions etc.
  2004-10-07  9:52 [Bug c/17880] New: -Wsequence-point doesn't warn inside if, while, do conditions, for beg/cond/end expressions etc jakub at gcc dot gnu dot org
@ 2004-10-07 10:09 ` giovannibajo at libero dot it
  2004-10-07 12:19 ` pinskia at gcc dot gnu dot org
  2004-10-12 17:12 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: giovannibajo at libero dot it @ 2004-10-07 10:09 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From giovannibajo at libero dot it  2004-10-07 10:09 -------
Notice, this is also related to PR 16202, which shows other cases where 
Wsequence-point is not working.

-- 


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


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

* [Bug c/17880] -Wsequence-point doesn't warn inside if, while, do conditions, for beg/cond/end expressions etc.
  2004-10-07  9:52 [Bug c/17880] New: -Wsequence-point doesn't warn inside if, while, do conditions, for beg/cond/end expressions etc jakub at gcc dot gnu dot org
  2004-10-07 10:09 ` [Bug c/17880] " giovannibajo at libero dot it
@ 2004-10-07 12:19 ` pinskia at gcc dot gnu dot org
  2004-10-12 17:12 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-10-07 12:19 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-10-07 12:19 -------
Cofirmed.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
           Keywords|                            |diagnostic
   Last reconfirmed|0000-00-00 00:00:00         |2004-10-07 12:19:33
               date|                            |


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


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

* [Bug c/17880] -Wsequence-point doesn't warn inside if, while, do conditions, for beg/cond/end expressions etc.
  2004-10-07  9:52 [Bug c/17880] New: -Wsequence-point doesn't warn inside if, while, do conditions, for beg/cond/end expressions etc jakub at gcc dot gnu dot org
  2004-10-07 10:09 ` [Bug c/17880] " giovannibajo at libero dot it
  2004-10-07 12:19 ` pinskia at gcc dot gnu dot org
@ 2004-10-12 17:12 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-10-12 17:12 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-10-12 17:04 -------
Note for the C++ front-end at this point we don't warn for the last for statement but we do for C, I 
have a fix for the problem (I fixed while fixing another problem).

-- 


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


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

end of thread, other threads:[~2004-10-12 17:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-07  9:52 [Bug c/17880] New: -Wsequence-point doesn't warn inside if, while, do conditions, for beg/cond/end expressions etc jakub at gcc dot gnu dot org
2004-10-07 10:09 ` [Bug c/17880] " giovannibajo at libero dot it
2004-10-07 12:19 ` pinskia at gcc dot gnu dot org
2004-10-12 17:12 ` 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).