[Bug c++/57693] The program logically failed in case of used "int b += b++"

manu at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Jun 24 10:05:00 GMT 2013


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

Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |manu at gcc dot gnu.org

--- Comment #4 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
> Both:
>  b += b++;
> And
>         d += d++;
> 
> are undefined what value b and d is going to be as there are no sequence
> point intbetween the two assignments.
> 
> They could be:
> temp = b;
> b++;
> b += temp;
> 
> or b++;
> b+=b;

Please, could we make more use of the FAQ? 

http://gcc.gnu.org/wiki/FAQ#undefinedbut

If you think the answer does not provide enough information, just extend the
answer there. (it could mention some example, and -Wsequence-points).

Otherwise, we have the same back and forth over and over again to the
frustration of users and the time waste of developers: what is UB? but my
program worked before! but my program works without optimizations! but I know
how it should work! can't gcc be consistent? but UB should not affect my
problem! I think this should not be UB!


More information about the Gcc-bugs mailing list