This happens with 4.1 but not with 4.0.x. It occurs even without -O. I believe java.util.LinkedHashMap is being miscompiled. You can see this by trying the test case in PR 20273. For me, it crashes.
In the debugger I observed that this line from LinkedHashMap$LinkedHashEntry.access() is incrementing the 'succ' field and not the modCount field: modCount++; -- Summary: miscompilation of LinkedHashMap Product: gcc Version: 4.1.0 Status: UNCONFIRMED Severity: normal Priority: P2 Component: java AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: tromey at gcc dot gnu dot org CC: gcc-bugs at gcc dot gnu dot org,java-prs at gcc dot gnu dot org GCC build triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21844