Re: __attribute__ to selectively disable -Wmaybe-uninitialized

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Oct 24, 2020 at 07:06:20PM +0200, Florian Weimer via Gcc-help wrote:
> * mark at yahoo via Gcc-help:
> 
> > The necessity to add many of these pragmas makes the code difficult to
> > read. Is there a variable attribute that could be used instead, 
> > something like:
> > char	*buffer __attribute__((uninitialized));
> 
> In the past, this has been suggested as an official way to suppress the
> warning:
> 
>   char *buffer = buffer;
> 
> See <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=36296#c3> for an
> example.
> 
> It has the downside that it is almost certainly not valid C++ and
> probably not valid C, either.

It isn't valid C, see 6.3.2.1/2, last sentence (accessing a var when it
is uninitialised, like the RHS of the assignment here does, is undefined
behaviour).  Yup.


Segher



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux