[comp.sys.hp] Optimizer bug in cc

dwho@jupiter.nmt.edu (David Olix) (09/20/90)

Since I can't seem to be able to report bugs to the Software Support
folks until we get our "official" ID number I figured I'd post this
here so everyone (hopefully at least someone at HP) will see....

Problem:     Optimizer bug in cc(1).
System:      HP9000/835 running HP-UX 7.0
Compiler ID: HP92453-01 A.07.10 HP C Compiler

Oversimplified description:
% cat ccbug.c
main()
{
  char *p;
  int i;

  i = 0;
  *(p = i - i);
}
% cc -v -O ccbug.c
/lib/cpp ccbug.c /tmp/ctmAAAa20274 -D__hp9000s800 -D__hppa -D__hpux -D__unix  
cc: Entering Preprocessor.
/lib/ccom /tmp/ctmAAAa20274 ccbug.o -O2 -v -Ac 
cc: Entering Scanner and Parser.
cc: Entering Semantic Analyzer.
cc: Entering Aliaser.
cc: Internal error 3277: Investigation required - Please contact HP Support.
%

I was also able to purturb internal errors 3265 and 3267 by using variants
of the above with the ternary operator.  Basically, I think it has something
to do with an incorrect implicit int --> char * conversion.  I know the C
program tries to dereference a NULL pointer, but that's not the point....


--David Olix                           |   And I *still* hate the Simpsons,
--dwho@{minos|jupiter|nmtvax}.nmt.edu  |   but I wanted a short .sig
-- 
Bulky and offensive .sig follows...

========================================================================
     >click<                |\/\/\/|

janm@eliot.UUCP (Jan Morales/Development) (09/20/90)

I was not able to reproduce this bug on my HP 9000/345 running HP-UX 6.5.
Maybe the 7.0 cc contains "improvements" over 6.5.  :-)

Transcript follows sig.

-- 
Jan Morales				E-mail:	uunet!eliot!janm
UNITECH Software, Inc.			Phone:	(703) 264-3301
1800 Alexander Bell Dr., Ste. 101
Reston, VA  22091  U.S.A.

-----------------------------------------------------------------------------
% cat ccbug.c
main()
{
	char *p;
	int i;

	i = 0;
	*(p = i - i);
}
% cc -v -O ccbug.c
ccbug.c:
	/lib/cpp  ccbug.c /tmp/ctm4DAAa02322
	/lib/cpass1  -Yo /tmp/ctm4DAAa02322 /tmp/ctm1AAAa02322
"ccbug.c", line 7: warning: incorrect combination of pointer and integer, op =
	/lib/c1  /tmp/ctm1AAAa02322 /tmp/ctm2BAAa02322
	/lib/cpass2  /tmp/ctm2BAAa02322 /tmp/ctm5EAAa02322
	/lib/c220  /tmp/ctm5EAAa02322 /tmp/ctm3CAAa02322
	/bin/as20  -o ccbug.o /tmp/ctm3CAAa02322
/bin/ld  /lib/crt0.o ccbug.o -x -lc
% ls -l a.out
-rwxr-xr-x   1 janm     devlpmt     5102 Sep 20 10:44 a.out
%

srf@hpcllca.HP.COM (Steve Folkman) (09/21/90)

A defect report was filed this morning against the HP C project
for the s800. The submission number was DTS 01141CLLca. 
No characterization is available yet.

Steve Folkman
1-447-0768

dave@dptechno.UUCP (Dave Lee) (09/21/90)

In article <1990Sep19.210628.10847@nmt.edu> dwho@jupiter.nmt.edu (David Olix) writes:
>Problem:     Optimizer bug in cc(1).
>System:      HP9000/835 running HP-UX 7.0
>Compiler ID: HP92453-01 A.07.10 HP C Compiler
>
>% cat ccbug.c
>main()
>{
>  char *p;
>  int i;
>
>  i = 0;
>  *(p = i - i);
>}
>% cc -v -O ccbug.c
>/lib/cpp ccbug.c /tmp/ctmAAAa20274 -D__hp9000s800 -D__hppa -D__hpux -D__unix  
>cc: Entering Preprocessor.
>/lib/ccom /tmp/ctmAAAa20274 ccbug.o -O2 -v -Ac 
>cc: Entering Scanner and Parser.
>cc: Entering Semantic Analyzer.
>cc: Entering Aliaser.
>cc: Internal error 3277: Investigation required - Please contact HP Support.
>%



I am unable to reproduce this bug on my 9000/345
uname -a says
HP-UX davesys 7.0 B 9000/375 davesys

Box says 9000 345.

cc -v -O ccbug.c 
ccbug.c:
        /lib/cpp  ccbug.c /tmp/ctm4DAAa05103
        /lib/cpass1  -Yo /tmp/ctm4DAAa05103 /tmp/ctm1AAAa05103
"ccbug.c", line 7: warning: incorrect combination of pointer and integer, op =
        /lib/c1  /tmp/ctm1AAAa05103 /tmp/ctm2BAAa05103
        /lib/cpass2  /tmp/ctm2BAAa05103 /tmp/ctm5EAAa05103
        /lib/c2  /tmp/ctm5EAAa05103 /tmp/ctm3CAAa05103
        /bin/as20  -o ccbug.o /tmp/ctm3CAAa05103
/bin/ld  /lib/crt0.o ccbug.o -x -lc


Everything OK.  
This must be a 800 series problem

I have no Idea where to get the "Compiler ID" from 


-- 
Dave Lee
uunet!dptechno!dave

mike@hpfcso.HP.COM (Mike McNelly) (09/21/90)

> I was not able to reproduce this bug on my HP 9000/345 running HP-UX 6.5.
> Maybe the 7.0 cc contains "improvements" over 6.5.  :-)
> 
> Transcript follows sig.
> 
> -- 
> Jan Morales				E-mail:	uunet!eliot!janm
> UNITECH Software, Inc.			Phone:	(703) 264-3301
> 1800 Alexander Bell Dr., Ste. 101
> Reston, VA  22091  U.S.A.

The original problem was posted against series 800.  It's unlikely that
any series 800 optimizer bug would be a bug in the series 300 optimizer
since they share no code whatsoever.  While optimization techniques are
in general pretty well known, their implementation and effectiveness are
very machine specific.

Series 300 optimization has a few bugs of its own but this isn't one of
them.

Mike McNelly
mike@hp.fc.com

mjs@hpfcso.HP.COM (Marc Sabatella) (09/22/90)

>The original problem was posted against series 800.  It's unlikely that
>any series 800 optimizer bug would be a bug in the series 300 optimizer
>since they share no code whatsoever.

As an aside, the original poster said that the dereference of NULL of was not
the issue.  Dereferencing NULL is in fact undefined (illegal?) in both K&R and
ANSI, so it is not completely surprising you didn't get whatever results you
expected, even though HP-UX does indeed try to define the result of NULL
pointer dereferences as either 0 or a segmentation violation.

Of course, even if one were to classify this as an error in the program, one
would like better error recovery :-)

Coincidentally, a similar construct broke the Series 300 code generator, too,
but that was caught in time.  In that case, it really was the explicit
dereference of NULL that caught the code generator by surprise.

--------------
Marc Sabatella (marc@hpmonk.fc.hp.com)
Disclaimers:
	2 + 2 = 3, for suitably small values of 2
	Bill and Dave may not always agree with me