gcc-bugs@gcc.gnu.org
[Top] [All Lists]

[Bug c/37947] missing sequence point warning for 'count += inc(&count);'

Subject: [Bug c/37947] missing sequence point warning for 'count += inc(&count);'
From: "manu at gcc dot gnu dot org"
Date: 29 Oct 2008 12:39:06 -0000

------- Comment #4 from manu at gcc dot gnu dot org  2008-10-29 12:39 -------
(In reply to comment #2)
>     counter += inc(&counter);
> 
> That is undefined code as you access counter without a sequence point where 
> you
> assign it.

Is it only undefined because inc modifies counter? We do not warn about this
and my improved patch for 4.5 neither catches this case. We could warn if the
argument to the function is a pointer to the written variable. However, I have
no idea how to do this within the current code of verify_tree. Suggestions
welcome.

I'll reopen this as an enhancement.


-- 

manu at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |manu at gcc dot gnu dot org
           Severity|normal                      |enhancement
             Status|RESOLVED                    |UNCONFIRMED
           Keywords|                            |diagnostic
         Resolution|INVALID                     |
            Summary|p->count += inc(p);  //     |missing sequence point
                   |value of p->count is wrong, |warning for 'count +=
                   |if inc(p) not only returns  |inc(&count);'
                   |an int but also increases p-|
                   |>counter                    |


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

<Prev in Thread] Current Thread [Next in Thread>