🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.sys.sgi.bugs
2 messages
2 total messages Started by Robert Almgren Sat, 09 Jan 1993 15:39
C++ and -mips2
#72
Author: Robert Almgren
Date: Sat, 09 Jan 1993 15:39
37 lines
1432 bytes
The program below compiles and runs properly with

    CC -o prog prog.C

but dumps core, apparently on the assignment, when compiled with

    CC -mips2 -o prog prog.C

It does the same with the -v2 flag.

Am I overlooking something obvious, or is something wrong with the
compiler?  (System is Crimson R4000; compilers are 3.10 release).

					Robert Almgren

					University of Chicago
					almgren@math.uchicago.edu

=====================================================================
			File "prog.C"

#include <stdlib.h>
#include <stdio.h>

main()
{
	printf("Beginning of program; allocating d\n");

	double *d = new double[3];
	printf("d has been allocated; setting d[0]\n");

	d[0] = 1.;
	printf("d[0] has been set; quitting\n");
}

=====================================================================
Re: C++ and -mips2
#73
Author: Martin Knoblauch
Date: Mon, 11 Jan 1993 07:57
67 lines
2768 bytes
In article <1993Jan9.153935.9091@midway.uchicago.edu>,
almgren@math.uchicago.edu (Robert Almgren) writes:
|> 
|> The program below compiles and runs properly with
|> 
|>     CC -o prog prog.C
|> 
|> but dumps core, apparently on the assignment, when compiled with
|> 
|>     CC -mips2 -o prog prog.C
|> 
|> It does the same with the -v2 flag.
|> 
|> Am I overlooking something obvious, or is something wrong with the
|> compiler?  (System is Crimson R4000; compilers are 3.10 release).
|> 
|> 					Robert Almgren
|> 
|> 					University of Chicago
|> 					almgren@math.uchicago.edu
|> 
|>
=====================================================================
|> 			File "prog.C"
|> 
|> #include <stdlib.h>
|> #include <stdio.h>
|> 
|> main()
|> {
|> 	printf("Beginning of program; allocating d\n");
|> 
|> 	double *d = new double[3];
|> 	printf("d has been allocated; setting d[0]\n");
|> 
|> 	d[0] = 1.;
|> 	printf("d[0] has been set; quitting\n");
|> }
|> 
|>
=====================================================================

  This is a known bug which has benn fixed for our next OS/compiler
release. It has to do with 'malloc(3)' from libc.a not allocating
doubles on double word boundaries, which is required by '-mips2'.

  For YOUR problem (there are others that can't be solved this
way) you can compile the program using:

CC prog.cc -o prog -mips2 -lC -lmalloc

  Be aware that you HAVE TO enter '-lC' before '-lmalloc'. The usage
'-lmalloc' should solve all simple alignment problems. An additional
benefit is the improved performance of the allocation algorithms in
'mallox(3x)'.

Martin
-- 
+---------------------------------+----------------------------------+
|Martin Knoblauch                 | Silicon Graphics GmbH            |
|Application Support              | Am Hochacker 3 - Technopark      |
|Silicon Graphics Computer Systems| W-8011 Grasbrunn-Neukeferloh, FRG|
|                                 | Phone: (+int) 89 46108-179 or -0 |
|                                 | Fax:   (+int) 89 46108-222       |
+---------------------------------+----------------------------------+
|Network: <knobi@sgi.com>         | V-Mail: 8935   | M/S: IMU-315    |
+--------------------------------------------------------------------+
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads