This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/68764] C frontend does not fold away trivial expressions that refer to const variables
- From: "rguenth at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 07 Dec 2015 13:29:42 +0000
- Subject: [Bug c/68764] C frontend does not fold away trivial expressions that refer to const variables
- Auto-submitted: auto-generated
- References: <bug-68764-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68764
--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Patrick Palka from comment #2)
> (In reply to Marek Polacek from comment #1)
> > I agree that this is weird but this is something the C FE likely shouldn't
> > do.
>
> One (possibly minor) obstacle with doing it in the middle-end is that the
> DECL_INITIALs of non-static local variables are cleared during
> gimplification so it is not all that simple to look up the definition of a
> const variable in order to fold away its uses.
Only if explicit assignments are instead added.