Akim Demaille <akim.demaille@xxxxxxxxx> writes: > I have some piece of C++ code where the order of evaluation of the function arguments does matter. Unfortunately, it's very easy to forget about that, and there's also tons of places where the order is undefined, but to no harm. > > Consider the following example: > > int impure() > { > static int a = 0; > return a++; > }; > > void foo(int, int) {} > > int main() > { > foo(impure(), impure()); > } > > Is there any way to have GCC warn about the undefined behavior? I'd be happy to tell impure is __attribute__((__impure__)) or something like that to teach it to teach me. Hi Akim. As far as I know, there is no existing warning for this sort of error. gcc will detect obvious cases in which a variable is modified twice with no intervening sequence points, but it won't detect them interprocedurally. Can you clearly define what the impure attribute would mean? In particular, should it warn about calling the same impure function twice without an intervening sequence point? Or should it complain about calling any two impure functions? I'm not really sure which would be more useful. Ian