r185035 - PR16467: Teach -Wunsequenced that in C11 (unlike C++11), an assignment's

Dimitry Andric dimitry at andric.com
Sat Jun 29 16:48:10 PDT 2013


On Jun 27, 2013, at 01:16, Richard Smith <richard-llvm at metafoo.co.uk> wrote:
> Author: rsmith
> Date: Wed Jun 26 18:16:51 2013
> New Revision: 185035
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=185035&view=rev
> Log:
> PR16467: Teach -Wunsequenced that in C11 (unlike C++11), an assignment's
> side-effect is not sequenced before its value computation. Also fix a
> mishandling of ?: expressions where the condition is constant that was
> exposed by the tests for this.


Hi Richard,

After this commit, the -Wunsequenced warning seems to have gotten a little too aggressive.  It now also warns about the following (admittedly silly) construction:

char *foo(char *p);

void bar(char *p)
{
  p = foo(++p);
}

// unseq.c:5:11: warning: multiple unsequenced modifications to 'p' [-Wunsequenced]
//   p = foo(++p);
//     ~     ^

Since a function call is a sequence point, the warning is not warranted in its current form.

Shall I re-open PR16467, or create a new PR?

-Dimitry





More information about the cfe-commits mailing list