http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54556
Bug #: 54556 Summary: [4.8 Regression] Marking implicitly pure variables as DECL_PURE_P leads to wrong code Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: fortran AssignedTo: unassig...@gcc.gnu.org ReportedBy: bur...@gcc.gnu.org CC: joost.vandevond...@mat.ethz.ch See PR 54389 and in particular PR 54389 comment 3. Joost writes there: This revision causes CP2K to produce wrong results at -O1 and above. Joost, if possible, can you nail down the file in which it occurs? That should be possible by looking at the .o files whether they change with or without the patch. I will try to come up with a scenario where implicit pure gets it wrong. Combining this with a failing test case is usually the best combination: One tends to find bugs both ways, but usually different ones. Besides having a bug in the implicit pure algorithm or in being unable to use it for this purpose, it might well be that the PURE handling in total has some bug, e.g. a slightly different semantic between Fortran and the middle end. If implicit pure is wrong, it will also affect other parts of the code. In any case, my working hypothesis is a bug in implicit pure. (With partial compilation, there might be also an issue when the .mod file claims implicit pure - and then the function gets changed to be no longer (implicitly) pure without recompilation of its users.) * * * Regarding the patch itself: http://gcc.gnu.org/viewcvs/trunk/gcc/fortran/trans-decl.c?r1=190757&r2=190756&pathrev=190757 The removal of "|| sym->attr.elemental" fixes a bug. Thus, if you backout the patch, only remove " || sym->attr.implicit_pure" and do not re-add "elemental".