/rdrive/ref/gcc/bin/g++48 -c mv1.cpp mv1.cpp:28:13: internal compiler error: Segmentation fault int j = fum(); ^ 0x84eaa07 crash_signal /rusers/sys_cron/grab_gcc/downloads_rel/4.8.1/gcc-4.8.1/gcc/toplev.c:332 0x868bd44 ix86_can_inline_p /rusers/sys_cron/grab_gcc/downloads_rel/4.8.1/gcc-4.8.1/gcc/config/i386/i386.c:4498 0x8102760 build_over_call /rusers/sys_cron/grab_gcc/downloads_rel/4.8.1/gcc-4.8.1/gcc/cp/call.c:7044 0x8106154 build_new_function_call(tree_node*, vec<tree_node*, va_gc, vl_embed>**, bool, int) /rusers/sys_cron/grab_gcc/downloads_rel/4.8.1/gcc-4.8.1/gcc/cp/call.c:3918 0x81bbdef finish_call_expr(tree_node*, vec<tree_node*, va_gc, vl_embed>**, bool, bool, int) /rusers/sys_cron/grab_gcc/downloads_rel/4.8.1/gcc-4.8.1/gcc/cp/semantics.c:2220 0x8176dd7 cp_parser_postfix_expression /rusers/sys_cron/grab_gcc/downloads_rel/4.8.1/gcc-4.8.1/gcc/cp/parser.c:5855 0x8178a82 cp_parser_unary_expression /rusers/sys_cron/grab_gcc/downloads_rel/4.8.1/gcc-4.8.1/gcc/cp/parser.c:6729 0x8179532 cp_parser_binary_expression /rusers/sys_cron/grab_gcc/downloads_rel/4.8.1/gcc-4.8.1/gcc/cp/parser.c:7421 0x8179ab0 cp_parser_assignment_expression /rusers/sys_cron/grab_gcc/downloads_rel/4.8.1/gcc-4.8.1/gcc/cp/parser.c:7657 0x8179f29 cp_parser_assignment_expression /rusers/sys_cron/grab_gcc/downloads_rel/4.8.1/gcc-4.8.1/gcc/cp/parser.c:7707 0x8179f29 cp_parser_constant_expression /rusers/sys_cron/grab_gcc/downloads_rel/4.8.1/gcc-4.8.1/gcc/cp/parser.c:7917 0x818303a cp_parser_init_declarator /rusers/sys_cron/grab_gcc/downloads_rel/4.8.1/gcc-4.8.1/gcc/cp/parser.c:16095 0x8184d49 cp_parser_simple_declaration /rusers/sys_cron/grab_gcc/downloads_rel/4.8.1/gcc-4.8.1/gcc/cp/parser.c:10670 0x81726d6 cp_parser_block_declaration /rusers/sys_cron/grab_gcc/downloads_rel/4.8.1/gcc-4.8.1/gcc/cp/parser.c:10551 0x818c2b4 cp_parser_declaration /rusers/sys_cron/grab_gcc/downloads_rel/4.8.1/gcc-4.8.1/gcc/cp/parser.c:10448 0x818c676 cp_parser_declaration_seq_opt /rusers/sys_cron/grab_gcc/downloads_rel/4.8.1/gcc-4.8.1/gcc/cp/parser.c:10334 0x818cac4 cp_parser_translation_unit /rusers/sys_cron/grab_gcc/downloads_rel/4.8.1/gcc-4.8.1/gcc/cp/parser.c:3813 0x818cac4 c_parse_file() /rusers/sys_cron/grab_gcc/downloads_rel/4.8.1/gcc-4.8.1/gcc/cp/parser.c:28338 0x8227d5a c_common_parse_file() /rusers/sys_cron/grab_gcc/downloads_rel/4.8.1/gcc-4.8.1/gcc/c-family/c-opts.c:1046 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See <http://gcc.gnu.org/bugs.html> for instructions. Test case: int fum (); // Extra declaration that is merged with the second one. int fum () __attribute__ ((target("default"))); #if 0 // gcc doesn't recognize cmov int fum () __attribute__((target( "cmov"))); #endif int fum () __attribute__((target( "mmx"))); int fum () __attribute__((target( "popcnt"))); int fum () __attribute__((target( "sse"))); int fum () __attribute__((target( "sse2"))); int fum () __attribute__((target( "sse3"))); int fum () __attribute__((target( "ssse3"))); int fum () __attribute__((target( "sse4.1"))); int fum () __attribute__((target( "sse4.2"))); int fum () __attribute__((target( "avx"))); int fum () __attribute__((target( "avx2"))); int fum () __attribute__((target("arch=core2"))); int fum () __attribute__((target("arch=corei7"))); int fum () __attribute__((target("arch=atom"))); int (*p)() = &fum; int j = fum();
Patch proposed to fix this problem: The problem here is that the caller to fum not from a function and current_function_decl is NULL when processing the call. The simple fix in call.c to check current_function_decl before calling can_inline_p target hook. * cp/call.c (build_over_call): Check if current_function_decl is NULL. * testsuite/g++.dg/ext/pr57548.C: New test. Index: cp/call.c =================================================================== --- cp/call.c (revision 199662) +++ cp/call.c (working copy) @@ -7053,7 +7053,8 @@ build_over_call (struct z_candidate *cand, int fla otherwise the call should go through the dispatcher. */ if (DECL_FUNCTION_VERSIONED (fn) - && !targetm.target_option.can_inline_p (current_function_decl, fn)) + && (current_function_decl == NULL + || !targetm.target_option.can_inline_p (current_function_decl, fn))) { fn = get_function_version_dispatcher (fn); if (fn == NULL) Index: testsuite/g++.dg/ext/pr57548.C =================================================================== --- testsuite/g++.dg/ext/pr57548.C (revision 0) +++ testsuite/g++.dg/ext/pr57548.C (revision 0) @@ -0,0 +1,25 @@ +/* { dg-do compile { target i?86-*-* x86_64-*-* } } */ +/* { dg-require-ifunc "" } */ + +int fum (); // Extra declaration that is merged with the second one. +int fum () __attribute__ ((target("default"))); + + +int fum () __attribute__((target( "mmx"))); +int fum () __attribute__((target( "popcnt"))); +int fum () __attribute__((target( "sse"))); +int fum () __attribute__((target( "sse2"))); +int fum () __attribute__((target( "sse3"))); +int fum () __attribute__((target( "ssse3"))); +int fum () __attribute__((target( "sse4.1"))); +int fum () __attribute__((target( "sse4.2"))); +int fum () __attribute__((target( "avx"))); +int fum () __attribute__((target( "avx2"))); + +int fum () __attribute__((target("arch=core2"))); +int fum () __attribute__((target("arch=corei7"))); +int fum () __attribute__((target("arch=atom"))); + +int (*p)() = &fum; + +int j = fum();
What happened to the patch?
(In reply to Paolo Carlini from comment #2) > What happened to the patch? http://gcc.gnu.org/ml/gcc-patches/2013-06/msg00426.html Patch has been submitted on Jun 7 in rev. 199842 to trunk. Sorry for not updating this bug. It can be marked fixed. Thanks Sri
Ok, thanks.