public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Segher Boessenkool <segher@kernel.crashing.org>
To: Florian Weimer <fweimer@redhat.com>
Cc: mark_at_yahoo via Gcc-help <gcc-help@gcc.gnu.org>
Subject: Re: __attribute__ to selectively disable -Wmaybe-uninitialized
Date: Sat, 24 Oct 2020 13:02:34 -0500	[thread overview]
Message-ID: <20201024180234.GM2672@gate.crashing.org> (raw)
In-Reply-To: <87ft63ft9v.fsf@oldenburg2.str.redhat.com>

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

      reply	other threads:[~2020-10-24 18:03 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <caf2f32f-3caf-fc89-0ca6-4c885a7b8ff1.ref@yahoo.com>
2020-10-23 20:01 ` mark_at_yahoo
2020-10-23 20:38   ` Segher Boessenkool
2020-10-23 21:51     ` mark_at_yahoo
2020-10-24  8:49       ` J Decker
2020-10-24 18:32       ` Segher Boessenkool
2020-10-27  8:01         ` mark_at_yahoo
2020-10-24 17:06   ` Florian Weimer
2020-10-24 18:02     ` Segher Boessenkool [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201024180234.GM2672@gate.crashing.org \
    --to=segher@kernel.crashing.org \
    --cc=fweimer@redhat.com \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).