This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/56930] New: regression: pointless -Wconversion warning with sizeof
- From: "jens.maurer at gmx dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 12 Apr 2013 07:11:17 +0000
- Subject: [Bug c++/56930] New: regression: pointless -Wconversion warning with sizeof
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56930
Bug #: 56930
Summary: regression: pointless -Wconversion warning with sizeof
Classification: Unclassified
Product: gcc
Version: 4.8.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: jens.maurer@gmx.net
int main()
{
int x = sizeof(int);
int y { sizeof(int) };
}
$ g++ -Wconversion -std=c++11 conv.cc
conv.cc: In function âint main()â:
conv.cc:3:17: warning: conversion to âintâ from âlong unsigned intâ may alter
its value [-Wconversion]
int x = sizeof(int);
^
gcc 4.7.x didn't warn about this case, and rightly so: There should be no
conversion warnings triggered if the compiler can detect that the value in
question is constant and no narrowing actually happens.
conv.cc:4:17: warning: conversion to âintâ from âlong unsigned intâ may alter
its value [-Wconversion]
int y { sizeof(int) };
^
The warning in this case is even more confusing: The compiler should generate a
language-mandated diagnostic if narrowing a non-constant, but the warning is
just besides the point at all.