help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem with g++ in linux


From: Robert Heller
Subject: Re: Problem with g++ in linux
Date: Thu, 15 Jul 2004 00:51:27 +0200

  roger@uanl.mx (Roger Z Rios),
  In a message on 14 Jul 2004 10:51:33 -0700, wrote :

RZR> I have a C++ code that compiles and runs perfectly under
RZR> the Sun CC compiler Solaris 7.  I am now trying
RZR> to run my code using Linux Suse gnu g++ 3.3.1.  Compilation
RZR> goes ok, but then, when running, I get a lot of
RZR> segmentation fault errors,  am I missing any flag??
RZR> The code is supposed to be standard C++.

A common cause of errors under Linux which *don't* show up (generally)
under Solaris are caused by under sized char arrays.

Consider this code (which contains a bug!):

char *pointer;

pointer = new[strlen("Hello World")];
strcpy(pointer,"Hello World");

This code will likely work just fine on a big-endian system (such as a
Sparc), but will in fact trash the heap on a little-endian system (such
as a ix86).

This code is *standard C++*.

RZR> 
RZR> Thanks for any input,
RZR> 
RZR> Dr Roger Rios
RZR> rios@colorado.edu
RZR>         

                                     \/
Robert Heller                        ||InterNet:   heller@cs.umass.edu
http://vis-www.cs.umass.edu/~heller  ||            heller@deepsoft.com
http://www.deepsoft.com              /\FidoNet:    1:321/153






                                                                                
                  


reply via email to

[Prev in Thread] Current Thread [Next in Thread]