public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "prasoonsaurav.nit at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/51834] -Wsequence-point fails when convoluted expressions with multiple side effects are used
Date: Thu, 12 Jan 2012 09:08:00 -0000	[thread overview]
Message-ID: <bug-51834-4-zuhLnV98kU@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-51834-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #2 from Prasoon <prasoonsaurav.nit at gmail dot com> 2012-01-12 09:07:52 UTC ---
@Richard Guenther 

Considering the expression i += (i,i++,i) +i;

(i,i++,i) involves change in the value of i, however comma introduces a
sequence point so very roughly considering it equivalent to
func(_some_side_effect_on_i)

we have i += func(_some_side_effect_on_i) + i;

Do you still think the behavior is well defined?

Another C++ example would be ++a = 10; where 'a'is of type int.
This invokes UB but there is no warning from the compiler side even after we
use this flag. Raising a similar bug for C++ because the differ may be
different in C and C++.

Thanks
Prasoon


  parent reply	other threads:[~2012-01-12  9:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-12  6:29 [Bug c/51834] New: " prasoonsaurav.nit at gmail dot com
2012-01-12  8:51 ` [Bug c/51834] " rguenth at gcc dot gnu.org
2012-01-12  9:08 ` prasoonsaurav.nit at gmail dot com [this message]
2012-01-12  9:20 ` schwab@linux-m68k.org
2012-04-19 15:07 ` vincent-gcc at vinc17 dot net

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-51834-4-zuhLnV98kU@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).