[Bug c++/55643] [4.7/4.8 Regression] [C++11] incorrect "warning:=?UTF-8?Q?=20variable=20=E2=80=98myVar=E2=80=99=20set=20but=20not=20used?=" with an "enum class"-typed variable is casted to double for the use
pinskia at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Dec 10 23:54:00 GMT 2012
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55643
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |diagnostic
Version|unknown |4.7.2
Summary|[4.7/4.8 Regression] g++ |[4.7/4.8 Regression]
|incorrectly prints |[C++11] incorrect
|"warning: variable ‘myVar’ |"warning: variable ‘myVar’
|set but not used |set but not used" with an
|[-Wunused-but-set-variable] |"enum class"-typed variable
|" when an "enum |is casted to double for the
|class"-typed variable is |use
|cast to double before use |
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-12-10 23:54:04 UTC ---
Here is a small testcase without any includes:
enum class MyEnum
{
eSomeValue = 123
};
void f(const char*, ...);
int main() {
MyEnum myVar = MyEnum::eSomeValue;
// As far as Wunused-but-set-variable is concerned, any of the following
// will successfully "use" myVar:
// printf("%d\n", myVar);
// printf("%d\n", (int)myVar);
// printf("%u\n", (unsigned)myVar);
// ...but these do not:
f("%f\n", (double)myVar);
f("%f\n", (float)myVar);
return 0;
}
More information about the Gcc-bugs
mailing list