What to do about compiler bug and source code?
Tomás Ó hÉilidheemail (remove spam text)
William Couture wrote:
I had a program before that worked perfectly on several different
platforms (Windows, Mac, Linux) with several different compilers until I
compiled it with the highest optimiser turned on for a particular
compiler ( -O3 with gcc ). Since the code worked perfectly on so many
different systems up until that point, my initial reaction was that
there must be a bug in the compiler. Anyway, the offending code turned
out to be:
void StrToLower(char *p)
while ( *p++ = tolower( (char unsigned)*p ) );
The problem here is that the behaviour is "unspecified" when it comes to
whether "*p++" or "*p" is evaluated first. For some reason, when I upped
the optimisation, "*p" became the expression that was evaluated first.
I'm not saying there's definitely not a bug in the compiler, but I'd
definitely scrutanise the code for sequence point violations and also
for unspecified behaviour. If you forced me to bet my house on what was
the problem, I'd reluctantly have to go with the code.
> I'm going to contact IAR shortly, but since I can't reproduce it in a
> sample fragment, I'm
> sure that IAR will want the entire source. But, since it has our
> propritary code, work
> does not want the source to be sent out.
> How would you handle this situation?
I'd be interested in glancing over the code if you wouldn't mind sending
me a snippet. I'd pay particular attention to lines of code that mention
the same variable name more than once.
In reply to: <firstname.lastname@example.org>
See also: www.piclist.com/techref/index.htm?key=what+about+compiler
You must be a member of the
piclist mailing list
(not only a www.piclist.com member) to post to the