Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how do I disable -Wuninitialized in a separate file?

1,064 views
Skip to first unread message

m_l_g3

unread,
Oct 27, 2008, 8:37:04 PM10/27/08
to
There is a big project, built for several target platforms, with
warnings treated as errors.

It used to compile ok under GCC 3.x, but with GCC 4.2 there are false
positive warnings like
"warning: ‘b’ may be used uninitialized in this function".

I know why the compiler thinks so; from some point of view, the
compiler is right, and the code probably should not have been written
like that... but the code has worked for years, and it is much safer
and cheaper not to touch it rather than re-factor it.

(Also, I do not want to workaround it by erasing large structures at
run-time in a performance-critical routine, because it is just plain
wrong, it is wrong to suppress warnings by inserting unnecessary
code.)

So I want to disable this "may be uninitialized" warning in a single
file.

But for some reason,
#pragma GCC diagnostic ignored "-Wuninitialized"
has no effect: I have the same warnings treated as errors.
(yes, I am sure I have inserted it to the copy that I compile rather
than elsewhere)

The gcc is:
gcc (GCC) 4.2.3 (Ubuntu 4.2.3-2ubuntu7)

an340

unread,
Jan 22, 2009, 4:59:59 PM1/22/09
to
m_l_g3 wrote:

> There is a big project, built for several target platforms, with
> warnings treated as errors.
>
> It used to compile ok under GCC 3.x, but with GCC 4.2 there are false
> positive warnings like

> "warning: ?b? may be used uninitialized in this function".


>
> I know why the compiler thinks so; from some point of view, the
> compiler is right, and the code probably should not have been written
> like that... but the code has worked for years, and it is much safer
> and cheaper not to touch it rather than re-factor it.
>
> (Also, I do not want to workaround it by erasing large structures at
> run-time in a performance-critical routine, because it is just plain
> wrong, it is wrong to suppress warnings by inserting unnecessary
> code.)
>
> So I want to disable this "may be uninitialized" warning in a single
> file.
>
> But for some reason,
> #pragma GCC diagnostic ignored "-Wuninitialized"
> has no effect: I have the same warnings treated as errors.
> (yes, I am sure I have inserted it to the copy that I compile rather
> than elsewhere)
>
> The gcc is:
> gcc (GCC) 4.2.3 (Ubuntu 4.2.3-2ubuntu7)

Option '-Wno-uninitialized' turns it off.

0 new messages