------- Comment #4 from aleksi dot nurmi at helsinki dot fi 2008-11-17 15:11 ------- I found an even shorter way to make it segfault, with no inline functions at all. It's an -O2 problem, then.
#include <stdio.h> struct iostream { FILE *f; }; static struct iostream our_stdin = { 0 }; void read_char(struct iostream* ios) { if (ios->f == 0) if (ios == &our_stdin) ios->f = stdin; fgetc(ios->f); } int main() { read_char(&our_stdin); return 0; } -- aleksi dot nurmi at helsinki dot fi changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|Inline accessor to stdin is |Accessor to stdin is breaks |breaks on -O2 optimization |on -O2 optimization http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38167