[Bug c/60090] For expression without ~, gcc -O1 emits "comparison of promoted ~unsigned with unsigned"
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60090 --- Comment #7 from Andrew Pinski --- This one still happens on the trunk even with PR 107465 fixed. The reason is because even though a warning here is correct, it is not wanted due to requiring constant folding. Note you can get also the incorrect warning wording at -O0 with constexpr in GCC 13+ (and -std=c2x).
[Bug c/60090] For expression without ~, gcc -O1 emits comparison of promoted ~unsigned with unsigned
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60090 Marek Polacek mpolacek at gcc dot gnu.org changed: What|Removed |Added Status|UNCONFIRMED |NEW Last reconfirmed||2014-02-06 CC||mpolacek at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #1 from Marek Polacek mpolacek at gcc dot gnu.org --- This (and a bunch of other related PRs) is about early folding in the FE. c_fully_fold when optimize calls fold_build2 - fold_binary_loc that transforms the expression and then we issue those seemingly unrelated warnings. I'd say that while we want the exprs to be folded, we should issue diagnostics for the unfolded exprs. (I think it's been discussed numerous times in the past.) Nothing for stage4, but we/I should address this in gcc 5.0.
[Bug c/60090] For expression without ~, gcc -O1 emits comparison of promoted ~unsigned with unsigned
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60090 --- Comment #2 from Marek Polacek mpolacek at gcc dot gnu.org --- C++ folds while parsing and here for both -O0 -O we get y.c: In function ‘int fn1(unsigned char, unsigned char)’: y.c:3:18: warning: comparison of promoted ~unsigned with unsigned [-Wsign-compare] return (l ^ a) != b; ^
[Bug c/60090] For expression without ~, gcc -O1 emits comparison of promoted ~unsigned with unsigned
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60090 --- Comment #3 from Chengnian Sun chengniansun at gmail dot com --- Thanks, Marek. May I ask another question on the Gcc optimizations and warnings? Is there a policy that the warnings should be independent of the optimization levels? That is, for all optimization levels, Gcc should always emit consistent warnings. I know that Clang has such a policy. But based on what I have observed on Gcc, it seems that Gcc does not have this policy.
[Bug c/60090] For expression without ~, gcc -O1 emits comparison of promoted ~unsigned with unsigned
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60090 --- Comment #4 from Marek Polacek mpolacek at gcc dot gnu.org --- I believe we strive for the warnings be independent of the optimization level, but it's not always possible, we have tons of bugs where -Wuninitialized depends on the optimization level, sometimes -Warray-bounds warns only on -O3, some warnings depend on VRP or SRA, on -O some uses are constant-propagated etc. In the middle-end we often warn only about variables in SSA form which are made, as a part of some optimization, non-addressable.
[Bug c/60090] For expression without ~, gcc -O1 emits comparison of promoted ~unsigned with unsigned
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60090 Manuel López-Ibáñez manu at gcc dot gnu.org changed: What|Removed |Added CC||manu at gcc dot gnu.org --- Comment #5 from Manuel López-Ibáñez manu at gcc dot gnu.org --- (In reply to Marek Polacek from comment #1) This (and a bunch of other related PRs) is about early folding in the FE. c_fully_fold when optimize calls fold_build2 - fold_binary_loc that transforms the expression and then we issue those seemingly unrelated warnings. I'd say that while we want the exprs to be folded, we should issue diagnostics for the unfolded exprs. (I think it's been discussed numerous times in the past.) Nothing for stage4, but we/I should address this in gcc 5.0. I think this should be the plan: http://gcc.gnu.org/ml/gcc/2013-11/msg00253.html but someone has to implement it ;-) In those cases where folding helps to avoid false positives, it would be nice to be able to still fold on-demand or to delay the warnings until folding can happen.
[Bug c/60090] For expression without ~, gcc -O1 emits comparison of promoted ~unsigned with unsigned
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60090 --- Comment #6 from Marek Polacek mpolacek at gcc dot gnu.org --- (In reply to Manuel López-Ibáñez from comment #5) http://gcc.gnu.org/ml/gcc/2013-11/msg00253.html Exactly. I hope I can tackle at least a part of it in next stage 1. In those cases where folding helps to avoid false positives, it would be nice to be able to still fold on-demand or to delay the warnings until folding can happen. Sure.