Re: [Late] F30 System-Wide Change proposal: GCC9

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

 



On Tue, Jan 29, 2019 at 02:12:03PM +0100, Jakub Jelinek wrote:
> On Tue, Jan 29, 2019 at 01:04:25PM +0000, Daniel P. Berrangé wrote:
> > The variable was already initialized right at the start. The compound
> > literal is just a short-hand for later changing the values in several
> > fields of the struct at once. This is no different to manually assigning
> > new values to each individual field one at a time. eg
> > 
> >   struct demo demo = {0};
> > 
> >   ...some code with a goto...
> > 
> >   demo = (struct demo) { .cmd = "foo" };
> 
> No, I wasn't talking about the demo variable, the warning is not about demo
> variable.  The warning is about the compound literal variable.
> That is an anonymous (when used at block scope automatic) variable, kind
> like:
>   struct demo __complit = { .cmd = "foo" };
>   demo = __complit;
> and with the goto you are crossing initialization of that variable.

Urgh. I would never have understood that from the warning message :-( It
is complaining about something that doesn't even exist as far as I was
concerned

> When you aren't taking address of this, the optimizers will likely optimize
> the temporary away later on, if you'd do &(struct demo) { .cmd = "foo" }
> that address could be used later on in the function, dereferenced etc.

Is it practical to get the warning supressed when code is not taking the
address of the anonymous var ?

If not then we pretty much have to abandon use of these anonymous
compound initializers for re-assigning existing variables :-(

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
_______________________________________________
devel mailing list -- devel@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://getfedora.org/code-of-conduct.html
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/devel@xxxxxxxxxxxxxxxxxxxxxxx




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Fedora Announce]     [Fedora Users]     [Fedora Kernel]     [Fedora Testing]     [Fedora Formulas]     [Fedora PHP Devel]     [Kernel Development]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Gimp]     [Yosemite News]

  Powered by Linux