The problem occurs while compiling systemc with gcc 3.4. It compiles normally with gcc 3.3 The details: $gcc -v Reading specs from /home/rafael/gcc_main/lib/gcc/i686-pc-linux-gnu/3.4/specs Configured with: ../gcc_main/configure --prefix=/home/rafael/gcc_main --enable-languages=c,c++ Thread model: posix gcc version 3.4 20031122 (experimental) Command: g++ -O3 -c sc_bv_base.ii g++ output: g++ -O3 -c src/systemc/datatypes/bit/sc_bv_base.ii In file included from ../../../../src/systemc/datatypes/bit/sc_proxy.h:51, from ../../../../src/systemc/datatypes/bit/sc_bit_proxies.h:41, from ../../../../src/systemc/datatypes/bit/sc_bv_base.h:41, from sc_bv_base.cpp:38: ../../../../src/systemc/datatypes/int/sc_unsigned.h:1939: internal compiler error: Falha de segmentação Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://gcc.gnu.org/bugs.html> for instructions.
Created attachment 5193 [details] the file that triggers the bug
Confirmed. Test case: namespace sc_dt { class sc_length_param { friend int compare_unsigned(int if_v_signed = 0); }; }
Nathan's patch for PR 9162 http://gcc.gnu.org/ml/gcc-cvs/2003-07/msg00137.html caused the regression.
Subject: Bug 13166 CVSROOT: /cvs/gcc Module name: gcc Changes by: lerdsuwa@gcc.gnu.org 2003-12-05 14:45:00 Modified files: gcc/cp : ChangeLog parser.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/parse: defarg6.C Log message: PR c++/13166 * parser.c (cp_parser_late_parsing_default_args): Make sure the context is a class before calling push_nested_class and pop_nested_class. * g++.dg/parse/defarg6.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3781&r2=1.3782 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/parser.c.diff?cvsroot=gcc&r1=1.126&r2=1.127 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3230&r2=1.3231 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/defarg6.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
The regression is fixed in the mainline. So it no longer ICE. However the behavior mentioned in DR136 (limiting which friend declaration can have default function argument) is not yet implemented. So I keep this bug report open, change keywords into an accept-invalid and adjust the summary accordingly.
Won't work on it for a long while.
I can still see [DR136] not being implemented in gcc version 4.8.2 , as I just noticed some code not compiling anymore with recent Clang 3.4 which by now implemented DR136: http://llvm.org/viewvc/llvm-project?view=revision&revision=184889 . g++ still compiles it fine although DR136 is violated (code in question is e.g. string.h of commoncpp2-1.8.0 ).
GCc 7.0 still accepts the small test case from comment #2. Clang rejects it with: t.C:4:13: error: friend declaration specifying a default argument must be a definition friend int compare_unsigned(int if_v_signed = 0); ^ 1 error generated.
Fixed by Paolo's patches for PR59480. *** This bug has been marked as a duplicate of bug 59480 ***