This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/58377] spurious "may be unused" warning with -Og


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58377

--- Comment #3 from Roland Dreier <rbd at debian dot org> ---
Even simpler test case for me:

$ cat x.cpp 
// gcc -Og -Wall -Werror -c x.cpp

int pop ();
int pop_first_bucket;

int my_pop ()
{
    int out;

    while (pop_first_bucket)
        if (pop_first_bucket && (out = pop()))
            return out;

    return 0;
}

$ for o in Og O0 O1 O2 O3 Ofast; do echo === $o ===; gcc -$o -Wall -Werror -c
x.cpp; done
=== Og ===
x.cpp: In function âint my_pop()â:
x.cpp:8:9: error: âoutâ may be used uninitialized in this function
[-Werror=maybe-uninitialized]
     int out;
         ^
cc1plus: all warnings being treated as errors
=== O0 ===
=== O1 ===
=== O2 ===
=== O3 ===
=== Ofast ===

Does not error when built as x.c:

$ cp x.cpp x.c; for o in Og O0 O1 O2 O3 Ofast; do echo === $o ===; gcc -$o
-Wall -Werror -c x.c; done
=== Og ===
=== O0 ===
=== O1 ===
=== O2 ===
=== O3 ===
=== Ofast ===

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]