This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/82557] New: Spurious -Wstrict-overflow warning with 32bit GCC
- From: "vindrg at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 15 Oct 2017 10:25:24 +0000
- Subject: [Bug c++/82557] New: Spurious -Wstrict-overflow warning with 32bit GCC
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82557
Bug ID: 82557
Summary: Spurious -Wstrict-overflow warning with 32bit GCC
Product: gcc
Version: 6.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: vindrg at gmail dot com
Target Milestone: ---
Created attachment 42370
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=42370&action=edit
Preprocessed settingsserializer.ii
Building qTox [qtox] on Debian 9 (stretch) i686 with GCC (Debian 6.3.0-18)
6.3.0 20170516 using -Wstrict-overflow produces a warning in the place where it
shouldn't.
It *does not* reproduce on amd64 system.
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