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

Andre Vehreschild vehre@gmx.de
Sat Jan 10 16:36:00 GMT 2015


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 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr60334_1.clog
Type: application/octet-stream
Size: 316 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20150110/10aa5816/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr60334_1.patch
Type: text/x-patch
Size: 2742 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20150110/10aa5816/attachment.bin>


More information about the Gcc-patches mailing list