[Fortran, Patch] PR60334 - Segmentation fault on character pointer assignments

Paul Richard Thomas paul.richard.thomas@gmail.com
Sun Jan 11 15:16:00 GMT 2015


Dear Andre,

This is OK for trunk. I have not been keeping track of whether or not
you have commit rights yet. If not, I will get to it sometime this
week.

Thanks for the patch.

Paul

On 10 January 2015 at 15:59, Andre Vehreschild <vehre@gmx.de> wrote:
> Hi all,
>
> attached patch fixes the bug reported in pr 60334. The issue here was that the
> function's result being (a pointer to) a deferred length char array. The string
> length for the result value was wrapped in a local variable, whose value was
> never written back to the string length of the result. This lead the calling
> routine to take the length of the result to be random leading to a crash.
>
> This patch addresses the issue by preventing the instantiation of the local
> var and instead using a reference to the parameter. This not only saves one
> value on the stack, but also because for small functions the compiler will hold
> all parameters in registers for a significant level of optimization, all the
> overhead of memory access (I hope :-).
>
> Bootstraps and regtests ok on x86_64-linux-gnu.
>
> - Andre
> --
> Andre Vehreschild * Kreuzherrenstr. 8 * 52062 Aachen
> Tel.: +49 241 9291018 * Email: vehre@gmx.de



-- 
Outside of a dog, a book is a man's best friend. Inside of a dog it's
too dark to read.

Groucho Marx



More information about the Gcc-patches mailing list