This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/70455] spurious "assuming signed overflow does not occur when simplifying conditional to constant [-Wstrict-overflow]"
- From: "vindrg at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 14 Oct 2017 14:26:02 +0000
- Subject: [Bug tree-optimization/70455] spurious "assuming signed overflow does not occur when simplifying conditional to constant [-Wstrict-overflow]"
- Auto-submitted: auto-generated
- References: <bug-70455-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70455
Vincas Dargis <vindrg at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |vindrg at gmail dot com
--- Comment #3 from Vincas Dargis <vindrg at gmail dot com> ---
This warning occurred when building qTox [qtox] on Debian 9 (stretch) i686 with
gcc (Debian 6.3.0-18) 6.3.0 20170516 when built with -Wstrict-overflow.
It *does not* reproduce on amd64 build.
Here's output:
/somewhere/qTox.git/src/persistence/settingsserializer.cpp:267: error: assuming
signed overflow does not occur when simplifying conditional to constant
[-Werror=strict-overflow]
if (g != -1) {
^~
Context [context]:
for (int g = -1; g < groups.size(); ++g) {
// Save the group name, if any
if (g != -1) {
writeStream(stream, RecordTag::GroupStart);
writeStream(stream, groups[g].toUtf8());
}
// ...
}
I could workaround it with:
if (static_cast<volatile int &>(g) != -1) {
Although maybe there is different solution?
[qtox] https://github.com/qTox/qTox
[context]
https://github.com/qTox/qTox/blob/084f3b06262b2ca8272238b2ec450d11840d7551/src/persistence/settingsserializer.cpp#L267