home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cs.utexas.edu!sun-barr!olivea!sgigate!odin!fido!knobi.munich.sgi.com!knobi
- From: knobi@knobi.munich.sgi.com (Martin Knoblauch)
- Newsgroups: comp.sys.sgi.bugs
- Subject: Re: C++ and -mips2
- Keywords: C++, mips2
- Message-ID: <1ir99jINNl4s@fido.asd.sgi.com>
- Date: 11 Jan 93 07:57:39 GMT
- References: <1993Jan9.153935.9091@midway.uchicago.edu>
- Organization: Silicon Graphics, Inc.
- Lines: 67
- NNTP-Posting-Host: knobi.munich.sgi.com
-
- 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 |
- +--------------------------------------------------------------------+
-