------- 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

Reply via email to