This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/33483] New: New warning suggestion (for -Wall): sizeof() with non-lvalue has side effects that will not execute at runtime
- From: "yuri at tsoft dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 18 Sep 2007 22:50:09 -0000
- Subject: [Bug c++/33483] New: New warning suggestion (for -Wall): sizeof() with non-lvalue has side effects that will not execute at runtime
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
#include <iostream>
using namespace std;
Here is a very dangerous situation that compiler can catch illustrated by the
following example: when sizeof has non-lvalue argument.
--- example ---
int f() {
cout << "I am f" << endl;
return 5;
}
int main() {
cout << "sizeof=" << sizeof(f()) << endl; // HERE THE WARNING SHOULD BE
ISSUED
return (0);
}
--
Summary: New warning suggestion (for -Wall): sizeof() with non-
lvalue has side effects that will not execute at runtime
Product: gcc
Version: 4.1.2
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: yuri at tsoft dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33483