On Thu, 17 Jan 2019 07:36:42 -0800, LeonT wrote: > On Thu, Jan 17, 2019 at 9:26 AM Fabian Groffen via RT > <perlbug-followup@perl.org> wrote: > > I think that the GCC compiler is actually doing "too smart" things > > here when optimisations are enabled. > > > > /usr/sfw/bin/gcc -O2 -> 4 > > gcc-6.4.0 -O2 -> 4 > > gcc-7.3.0 -O2 -> 4 > > gcc-8.2.0 -O2 -> 0 > > /usr/sfw/bin/gcc -g -> 4 > > gcc-6.4.0 -g -> 4 > > gcc-7.3.0 -g -> 4 > > gcc-8.2.0 -g -> 4 > > > > Behaviour seems to be pretty much limited to gcc-8.2 while optimising > > at the moment. > > Yeah. I guess that means we need a better test that confuses the > compiler a little bit more. One would expect volatile to take care of > that but apparently not; The C standard is notoriously fuzzy on > volatiles (C99 6.7.6). > > What happens if you put the array outside the function? The results are the same, unfortunately. > > > Yes, including the fact that at the time I compiled 5.26.2, I used > > GCC-7.3, which produced the correct result for the unaligned check. > > > > This makes me wonder what the problem of OP is, though. His env > > seems to suggest using GCC-4.9, which I don't have anymore for > > verification of the results. > > They did use -O3, so I guess that always enabled that optimization. It seems you're correct about that (code from original test): /usr/sfw/bin/gcc -O3 -> 4 gcc-6.4.0 -O3 -> 0 gcc-7.3.0 -O3 -> 0 gcc-8.2.0 -O3 -> 0 /usr/sfw/bin/gcc -O2 -> 4 gcc-6.4.0 -O2 -> 4 gcc-7.3.0 -O2 -> 4 gcc-8.2.0 -O2 -> 0 /usr/sfw/bin/gcc -g -> 4 gcc-6.4.0 -g -> 4 gcc-7.3.0 -g -> 4 gcc-8.2.0 -g -> 4 Fabian --- via perlbug: queue: perl5 status: open https://rt.perl.org/Ticket/Display.html?id=133495