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 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.
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.

	Jakub
_______________________________________________
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