This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: wrong-code bug in gcc-4.5.x?


On 04/25/2011 08:00 PM, Ian Lance Taylor wrote:
Wouter Vermaelen<wouter.vermaelen@scarlet.be> writes:

I believe I found a wrong-code bug. The problem triggers when using
gcc-4.5.1, 4.5.2 or 4.5.3, but not when using 4.4.5 or 4.7.0 (snapshot
20110419). It also only triggers with certain optimization levels/flags.
I wonder if this is a known problem and already fixed in 4.7.0, or that
the problem still exists but for some reason doesn't trigger in 4.7.0
(I couldn't easily find something in bugzilla).

Below is a reduced test-case that shows the problem. I tried, but I
couldn't get it smaller than these 4 files (combined about 60 lines).

While reducing this problem I realized that it *might* not be a compiler
bug, but undefined behaviour with the usage of __restrict in
Buffer::read(). What I wanted to express there is that the memory write
done by memcpy() can never overwrite the member variable 'p'. At the
moment I still believe it's a compiler bug, but I'm not 100% sure
anymore.

So is this a compiler bug or undefined behaviour in my program? In case
of the latter I would appreciate if someone could explain what the
problem is and maybe suggest a way to fix it.

I don't see anything wrong with your use of __restrict here. If this programs works without __restrict and fails with __restrict then I think this is a compiler bug.

Ok, thanks. I've reported it as bug 48764:


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48764


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]