diff options
author | Alex Cherepanov <alex.cherepanov@artifex.com> | 2011-11-27 13:23:46 -0500 |
---|---|---|
committer | Chris Liddell <chris.liddell@artifex.com> | 2012-03-15 11:54:10 +0000 |
commit | b6b5e641b5c739c14465a3e5eaf17b5b1e5adcc0 (patch) | |
tree | f5e2a2a0b474308924782df64aca057aa8588561 /gs/psi | |
parent | b5095f6d3d84010f7e001c2e8966839744ef0fbf (diff) |
Bug 692684: stop gcc optimization bug.
Divide gs_main_init2() into two functions to work around a bug in
gcc 4.5.1 with -O2 option. The bug caused gcc to drop 2nd
assignment to i_ctx_p and resulted in SEGV error later on.
Diffstat (limited to 'gs/psi')
-rw-r--r-- | gs/psi/imain.c | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/gs/psi/imain.c b/gs/psi/imain.c index fd329f772..4044ec180 100644 --- a/gs/psi/imain.c +++ b/gs/psi/imain.c @@ -241,15 +241,14 @@ gs_main_interpret(gs_main_instance *minst, ref * pref, int user_errors, return code; } -int -gs_main_init2(gs_main_instance * minst) -{ - i_ctx_t *i_ctx_p; - int code = gs_main_init1(minst); +/* gcc wants prototypes for all external functions. */ +int gs_main_init2aux(gs_main_instance * minst); + +/* This is an external function to work around */ +/* a bug in gcc 4.5.1 optimizer. See bug 692684. */ +int gs_main_init2aux(gs_main_instance * minst) { + i_ctx_t * i_ctx_p = minst->i_ctx_p; - if (code < 0) - return code; - i_ctx_p = minst->i_ctx_p; if (minst->init_done < 2) { int code, exit_code; ref error_object; @@ -292,6 +291,21 @@ gs_main_init2(gs_main_instance * minst) return code; #endif /* PSI_INCLUDED */ } + return 0; +} + +int +gs_main_init2(gs_main_instance * minst) +{ + i_ctx_t *i_ctx_p; + int code = gs_main_init1(minst); + + if (code < 0) + return code; + i_ctx_p = minst->i_ctx_p; + code = gs_main_init2aux(minst); + if (code < 0) + return code; i_ctx_p = minst->i_ctx_p; /* display_set_callback or run_string may change it */ if (gs_debug_c(':')) print_resource_usage(minst, &gs_imemory, "Start"); |