This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/33483] New warning suggestion (for -Wall): sizeof() with non-lvalue has side effects that will not execute at runtime
- From: "msebor at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 11 Oct 2015 23:08:10 +0000
- Subject: [Bug c++/33483] New warning suggestion (for -Wall): sizeof() with non-lvalue has side effects that will not execute at runtime
- Auto-submitted: auto-generated
- References: <bug-33483-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=33483
--- Comment #4 from Martin Sebor <msebor at gcc dot gnu.org> ---
It might makes sense to provide the functionality under the
-Wunevaluated-expression option for compatibility with clang:
$ cat u.c && clang -Wall -c u.c
int foo (int i)
{
int a [i];
return sizeof (a [i++]);
}
u.c:4:19: warning: expression with side effects has no effect in an unevaluated
context [-Wunevaluated-expression]
return sizeof (a [i++]);
^
1 warning generated.