public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/102276] -ftrivial-auto-var-init fails to initialize a variable, causes a spurious warning Date: Mon, 14 Feb 2022 07:26:33 +0000 [thread overview] Message-ID: <bug-102276-4-pj9RLEtmDz@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-102276-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102276 --- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> --- It's difficult, see the recent discussion on introducing explicit live-in markers for the purpose of stack slot sharing and exactly these case of testcases. The "simplest" suggestion was to promote the variable to an outer scope when such entry into the containing scope is detected. But since we are doing auto-init at gimplification time the new point of initializaton would need to be computed before somehow. Since you are getting a diagnostic which we could even improve to warning: variable auto-init for `x' will never be executed and you do like to get auto-init and you _can_ fix your code that's all perfectly OK. Yes, there might be a way to compute auto-init locations (! yes, multiple, with obvious code-size impact) or a more conservative location (extending the variable lifetime with the corresponding effect on stack slot sharing). But clearly fixing the source is prefered. Mind that when you write int g(int *); int f1() { switch (0) { int x = 0; default: return g(&x); } } you get the very same effect. So IMHO -ftrivial-auto-var-init behaves _exactly_ as one would assume it would, without doing any invisible magic dances. So yes, let's improve the diagnostic to be specific about each variable that is not initialized (and maybe the following still unreachable stmt).
next prev parent reply other threads:[~2022-02-14 7:26 UTC|newest] Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-09-10 14:17 [Bug middle-end/102276] New: " amonakov at gcc dot gnu.org 2021-09-13 10:14 ` [Bug middle-end/102276] " rguenth at gcc dot gnu.org 2021-09-13 17:50 ` amonakov at gcc dot gnu.org 2021-09-14 17:55 ` kees at outflux dot net 2022-02-12 18:14 ` kees at outflux dot net 2022-02-12 20:22 ` pinskia at gcc dot gnu.org 2022-02-14 7:26 ` rguenth at gcc dot gnu.org [this message] 2022-02-14 16:08 ` jakub at gcc dot gnu.org 2022-02-14 17:02 ` qinzhao at gcc dot gnu.org 2022-02-14 23:21 ` qinzhao at gcc dot gnu.org 2022-02-15 8:16 ` rguenther at suse dot de 2022-02-15 16:02 ` qinzhao at gcc dot gnu.org 2022-02-15 19:55 ` qinzhao at gcc dot gnu.org 2022-02-17 7:22 ` rguenther at suse dot de 2022-02-17 19:57 ` qinzhao at gcc dot gnu.org 2022-03-02 16:55 ` cvs-commit at gcc dot gnu.org 2022-03-02 16:56 ` qinzhao at gcc dot gnu.org
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=bug-102276-4-pj9RLEtmDz@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@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: linkBe 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).