delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1994/03/15/16:00:56

Date: Tue, 15 Mar 1994 13:35:18 -0700
From: tesla AT lamar DOT ColoState DOT EDU (Jon Nash)
To: djgpp AT sun DOT soe DOT clarkson DOT edu
Subject: Compiler Aborts! Why? (Solved)

Well, the mystery gives way...  The problem can be summed up in a few lines
of code...  (my fault for being sloppy in the first place:) )

#include <Complex.h>
#include <iostream.h>

Complex *u;

int main(void)
{
  float z=5.0;

  u = new Complex[z];
  cout<<"Watch me Abort!\n";
  return 1;
}

This code will make the compiler Abort! with no warning messages.

I found this error when (I forgot exactly who suggested this - Thanks to
who ever it was!) I tried to compile my code on the RS/6000 xlC compiler.

The error that compiler gave was
  "float" cannot be converted to "int"
  "float*" cannot be converted to "complex*"
So if I just say
  u = new Complex[int(z)];
everything works great!

It was a dumb mistake, but I sure wish the compiler would give a better
warning then "Abort!"

Thanks to all who helped me!  DJ - I hope you see this note before you spend
too much time playing with my code!

Sincerely,

Jon Nash
Tesla AT Lamar DOT ColoState DOT EDU
Colorado State University
Physics Department

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019