[Bug c++/26298] -Wconversion fails to detect signedness change during widening conversion
--- Comment #6 from mueller at gcc dot gnu dot org 2006-10-16 15:37 --- *** This bug has been marked as a duplicate of 26167 *** -- mueller at gcc dot gnu dot org changed: What|Removed |Added Status|NEW |RESOLVED Resolution||DUPLICATE http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26298
[Bug c++/26298] -Wconversion fails to detect signedness change during widening conversion
--- Comment #5 from rguenth at gcc dot gnu dot org 2006-09-17 21:02 --- Well, you are right. This bug is a dup of the bug requesting -Wcoercion (if we have such). -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26298
[Bug c++/26298] -Wconversion fails to detect signedness change during widening conversion
--- Comment #3 from rguenth at gcc dot gnu dot org 2006-09-16 17:08 --- 26167, the one I added in the dependencies -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26298
[Bug c++/26298] -Wconversion fails to detect signedness change during widening conversion
--- Comment #4 from lopezibanez at gmail dot com 2006-09-16 19:45 --- Richard, and what is your opinion about the rest of my comment? -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26298
[Bug c++/26298] -Wconversion fails to detect signedness change during widening conversion
--- Comment #2 from lopezibanez at gmail dot com 2006-09-16 01:38 --- Richard, could you tell which bug report do you mean? The -Wconversion warnings does not apply to this case. Wconversion warns about the effect of adding a prototype, not about sign conversions. Anyway, I still don't understand where is the bug. Unary minus applied to unsigned (what typically is the type of sizeof()) gives: `2^n - i', where `n' is the number of bits in the unsigned type. [1] So actually -sizeof(int) is 4294967292 (assuming sizeof(int) is 4). This number fits well in a signed long long. However, it doesn't fit in a signed int, and thus, it wraps around and produces -4. The -Wcoercion flag provided by the Wcoercion project [2] warns for the wrap-around as: pr26298.c:15: warning: coercion as 'int' alters 'unsigned int' constant value [1] http://gcc.gnu.org/ml/gcc/1999-06n/msg00754.html [2] http://gcc.gnu.org/wiki/Wcoercion -- lopezibanez at gmail dot com changed: What|Removed |Added CC||lopezibanez at gmail dot ||com, rguenth at gcc dot gnu ||dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26298
[Bug c++/26298] -Wconversion fails to detect signedness change during widening conversion
--- Comment #1 from rguenth at gcc dot gnu dot org 2006-02-15 10:36 --- With -Wconversion you get t.c:5: warning: passing argument 1 of toLongLong with different width due to prototype though -Wconversion is neither in -Wall nor -Wextra. I see you filed against C++, which doesn't warn here, but we have a bug for a similar case already. Also the C diagnostic could be improved in the case of a widening sign conversion, because that is more likely an error than a non-widening sign conversion. -- rguenth at gcc dot gnu dot org changed: What|Removed |Added BugsThisDependsOn||26167 Severity|normal |enhancement Status|UNCONFIRMED |NEW Ever Confirmed|0 |1 Keywords||diagnostic Last reconfirmed|-00-00 00:00:00 |2006-02-15 10:36:07 date|| Summary|no warning for implicit type|-Wconversion fails to detect |conversion |signedness change during ||widening conversion http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26298