Usenet comp.sys.dec (1990-2013)
 help / color / mirror / Atom feed
* Compiler Bug
@ 1990-07-26  5:41 Peter Davids
  1990-07-26 13:50 ` Jim Gettys
  1990-07-27 15:29 ` Steve V. Hodsdon
  0 siblings, 2 replies; 3+ messages in thread
From: Peter Davids @ 1990-07-26  5:41 UTC (permalink / raw)




Some days (or weeks) ago, there was a posting in comp.sys.dec or
comp.unix.ultrix that described a compiler bug in Ultrix CC.

We have DEC 3100 Workstation with Ultrix 3.1 and UWS 2.1 running.
The following little (and correct!?) C-program gives different results,
depending on the optimizer options.
The programm look a bit like the own posted some time ago...


====cut here==============================
char *   malloc();

main()
{
  char *   ba;
  int i=3;
  printf("%d\n", i*(-6) );
  ba = malloc (100);
  printf("%d\n", i*(-6) );
}

/*
 *   Results: 
 *   
 *   Compile with:	'cc b.c'		default
 *   
 *   -18
 *   18
 *   
 *   
 *    
 *   Compile with:	'cc -O  b.c'		optimize
 *   
 *   -18
 *   -18
 *   
 *   
 *   
 *   Compile with:	'cc -O0 b.c'		don't optimize
 *   
 *   18
 *   18
 *   
 *
 */
=====================================================================

Questions

	o	Does anybody know the reasons for this behaviour
	o	Are results the same unter Ultrix 3.0 or 4.0
		(we only have 3.1)
	o	Is there any solution around that problem.


I will be happy about any idea or answer (other bugs would be also
very interesting)

--
_________________________________________________________________________
Peter Davids   Lehrstuhl fuer Informatik IV   RWTH Aachen   D-5100 Aachen
Tel. +241-804522    Fax: +241-806295     davids@informatik.rwth-aachen.de


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Compiler Bug
  1990-07-26  5:41 Compiler Bug Peter Davids
@ 1990-07-26 13:50 ` Jim Gettys
  1990-07-27 15:29 ` Steve V. Hodsdon
  1 sibling, 0 replies; 3+ messages in thread
From: Jim Gettys @ 1990-07-26 13:50 UTC (permalink / raw)


Sounds like a bug under 3.1....

Results under 4.0 (which has a new compiler suite...)
cat >foo.c
char *   malloc();

main()
{
  char *   ba;
  int i=3;
  printf("%d\n", i*(-6) );
  ba = malloc (100);
  printf("%d\n", i*(-6) );
}
zorch % cc -O foo.c -o foo
zorch % foo
-18
-18
zorch % cc foo.c -o foo
zorch % foo
-18
-18
zorch % cc -O0 foo.c -o foo
zorch % foo
-18
-18
zorch % cc -O3 foo.c -o foo
zorch % foo
-18
-18
zorch % cc -O4 foo.c -o foo
zorch % foo
-18
-18
zorch % cc -O1 foo.c -o foo
zorch % foo
-18
-18
zorch %


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Compiler Bug
  1990-07-26  5:41 Compiler Bug Peter Davids
  1990-07-26 13:50 ` Jim Gettys
@ 1990-07-27 15:29 ` Steve V. Hodsdon
  1 sibling, 0 replies; 3+ messages in thread
From: Steve V. Hodsdon @ 1990-07-27 15:29 UTC (permalink / raw)


In article <3152@rwthinf.UUCP>, davids@bduxpe (Peter Davids) writes:
> 
> We have DEC 3100 Workstation with Ultrix 3.1 and UWS 2.1 running.
> The following little (and correct!?) C-program gives different results,
> depending on the optimizer options.
> The programm look a bit like the own posted some time ago...
> 
> 
> ====cut here==============================
> char *   malloc();
> 
> main()
> {
>   char *   ba;
>   int i=3;
>   printf("%d\n", i*(-6) );
>   ba = malloc (100);
>   printf("%d\n", i*(-6) );
> }
> 
> I will be happy about any idea or answer (other bugs would be also
> very interesting)

I am running a MIPS box with the R2600 CPU card (R2000 processor).

Here is the output: (using uMIPS 2.0)

[shodsdon@(bifur)/u/shodsdon/src]
3 %cc b.c
[shodsdon@(bifur)/u/shodsdon/src]
4 %a.out
-18
18
[shodsdon@(bifur)/u/shodsdon/src]
5 %cc -O b.c
[shodsdon@(bifur)/u/shodsdon/src]
6 %a.out
-18
-18
[shodsdon@(bifur)/u/shodsdon/src]
7 %cc -O0 b.c
[shodsdon@(bifur)/u/shodsdon/src]
8 %a.out
18
18


Kinda makes you wonder.

> _________________________________________________________________________
> Peter Davids   Lehrstuhl fuer Informatik IV   RWTH Aachen   D-5100 Aachen
> Tel. +241-804522    Fax: +241-806295     davids@informatik.rwth-aachen.de


-- 
Steve Hodsdon                          | Stay sane inside insanity.
shodsdon@elrond.CalComp.COM            | Don't dream it -  Be it.
{decvax|harvard}!elrond!shodsdon       |
(603) 885-8324                         |


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1990-07-27 15:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1990-07-26  5:41 Compiler Bug Peter Davids
1990-07-26 13:50 ` Jim Gettys
1990-07-27 15:29 ` Steve V. Hodsdon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox