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

Reply via email to