-
Notifications
You must be signed in to change notification settings - Fork 15.5k
Closed
Labels
bugzillaIssues migrated from bugzillaIssues migrated from bugzillacclang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerconfirmedVerified by a second partyVerified by a second party
Description
| Bugzilla Link | 48666 |
| Version | 11.0 |
| OS | All |
| CC | @DougGregor,@zygoloid |
Extended Description
Consider the C compilation unit:
int Y, Z;
void f(int n) {
long u[n];
Y = sizeof *(Z=1, &u);
}
Clang warns that the side-effect “Z=1” will have no effect because it's an unevaluated context, but actually, u is a VLA, and in this case side-effects happen. Note that the code generated by Clang is correct, it is only the warning that should not be emitted:
Generated code with -O:
f: # @f
movl $1, Z(%rip)
shll $3, %edi
movl %edi, Y(%rip)
retq
Compiler Explorer link: https://gcc.godbolt.org/z/PG9cd9
The relevant C17 clause: https://cigix.me/c17#6.5.3.4.p2
Metadata
Metadata
Assignees
Labels
bugzillaIssues migrated from bugzillaIssues migrated from bugzillacclang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerconfirmedVerified by a second partyVerified by a second party