This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/66512] PRE fails to optimize calls to pure functions in C++, ok in C
- 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: Thu, 18 Jun 2015 11:15:33 +0000
- Subject: [Bug tree-optimization/66512] PRE fails to optimize calls to pure functions in C++, ok in C
- Auto-submitted: auto-generated
- References: <bug-66512-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66512
--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Alexander Monakov from comment #2)
> In that case I'd like to contribute a documentation patch to make that clear
> in the pure/const attribute information, but I need more explanation. I see
> that
>
> int p(void) __attribute__((const));
> void f()
> {
> p();
> p();
> }
>
> is optimized to an empty function, even though p may throw. Is that not a
> bug?
I would say so. But this has quite some implementation issues, also with...
> Also, could you please expand your explanation in the first paragraph, i.e.
> this:
>
> What we miss here is the fact that it should only matter
> if p throws internally for IL consistency. Of course it
> still matters for observing other side-effects if p throws
> and after the transform now does so before side-effects
> that should be observed otherwise.
>
> I'm probably missing a lot of contextual knowledge to understand that. TIA.
... this, the side-effect ordering of stores and the throwing p() call is
not properly represented.