Regarding code portability across different gcc/g++ versions

Andrew Haley aph@redhat.com
Thu Sep 30 00:24:00 GMT 2010


On 09/29/2010 08:07 AM, #SINHA SHARAD# wrote:
> Hi,
>  
>     I had a big piece of code that ran smoothly on gcc 3.2.2. For
> some reason, I had to start using that code on a machine with GCC
> 4.2.1. Now, it would throw segmentation faults (invalid free pointer
> etc) and abort the program. I presume this happens because the glibc
> with gcc 4.2.1 is smarter than the one with gcc 3.2.2. Hence, what
> was missed during execution with 3.2.2 was caught in 4.2.1

Maybe; it's hard to say without more investigation.

>     While it is great to catch as many errors as possible, will it
> not be better that execution support for code running on earlier
> versions was provided?

That's not generally possible, because we don't know all the crazy
things programmers do.

> May be what was missed in earlier versions should be flagged as
> "error with the current gcc version" or something like that and it
> does not abort the program thus continuing its execution leaving the
> developer with the option to fix the error later.

We don't deliberately generate code that segfaults, I assure you.

> Since, the code size in my case is very big and the original
> developer is not there to support, it is extremely difficult to
> resolve this issue.

I suggest you start with Valgrind's memory checker.

Andrew.



More information about the Gcc mailing list