Hi, The following program segfaults when compiled with gcc but runs fine when compiled with g++ or icc (the intel C compiler)
#include <stdio.h> struct Hello { char world[20]; }; struct Hello s(){ struct Hello r; r.world[0]='H'; r.world[1]='\0'; return r; } int main(){ printf("%s\n",s().world); }Assigning s() to a variable and then using the variable avoids the segfault.
gcc --version returns (GCC) 4.2.4 (Ubuntu 4.2.4-1ubuntu3). Regards, Michel