Bug 49264 - [4.6/4.7 Regression] Internal compiler error: segmentation fault
Summary: [4.6/4.7 Regression] Internal compiler error: segmentation fault
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: 4.6.1
Assignee: Jakub Jelinek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-01 21:09 UTC by Dimitris Eftaxiopoulos
Modified: 2011-06-06 18:01 UTC (History)
1 user (show)

See Also:
Host: x86_64-linux-gnu
Target: x86_64-linux-gnu
Build: x86_64-linux-gnu
Known to work: 4.5.3
Known to fail: 4.6.0, 4.7.0
Last reconfirmed: 2011-06-01 23:25:53


Attachments
Preprocessed file that triggers the bug (149.35 KB, application/x-compressed-tar)
2011-06-02 11:49 UTC, Dimitris Eftaxiopoulos
Details
pr49264.ii (1.38 KB, text/plain)
2011-06-02 14:45 UTC, Jakub Jelinek
Details
gcc46-pr49264.patch (1.26 KB, patch)
2011-06-03 07:47 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dimitris Eftaxiopoulos 2011-06-01 21:09:59 UTC
$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.6.1/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.6.0-10' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++,go --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-multiarch --with-multiarch-defaults=x86_64-linux-gnu --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-plugin --enable-objc-gc --with-arch-32=i586 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.6.1 20110526 (prerelease) (Debian 4.6.0-10)


$ g++ -DHAVE_CONFIG_H -I. -I../.. -I../lglib -I../bamglib -I../Graphics -I../femlib    -g  -DNDEBUG -O3 -mmmx -msse -msse2 -DDRAWING -DBAMG_LONG_LONG  -DNCHECKPTR -fPIC -c -fno-strict-aliasing -fwrapv -save-temps -Wall -Wextra -o array_long.o array_long.cpp
In file included from array_tlp.hpp:34:0,
                 from array_long.cpp:28:
AFunction.hpp:1422:15: warning: unused parameter ‘i’ [-Wunused-parameter]
AFunction.hpp:1454:11: warning: unused parameter ‘k’ [-Wunused-parameter]
AFunction.hpp:1739:13: warning: unused parameter ‘r’ [-Wunused-parameter]
AFunction.hpp:1739:13: warning: unused parameter ‘top’ [-Wunused-parameter]
In file included from array_tlp.hpp:34:0,
                 from array_long.cpp:28:
AFunction.hpp:2233:19: warning: unused parameter ‘a’ [-Wunused-parameter]
AFunction.hpp:2233:19: warning: unused parameter ‘b’ [-Wunused-parameter]
In file included from array_tlp.hpp:34:0,
                 from array_long.cpp:28:
AFunction.hpp:2872:18: warning: type qualifiers ignored on function return type [-Wignored-qualifiers]
AFunction.hpp:2944:13: warning: unused parameter ‘l’ [-Wunused-parameter]
AFunction.hpp:2944:13: warning: unused parameter ‘top’ [-Wunused-parameter]
In file included from array_long.cpp:28:0:
array_tlp.hpp: In function ‘void ArrayOperator() [with K = long int, Z = long int]’:
array_long.cpp:135:31:   instantiated from here
array_tlp.hpp:871:12: warning: unused variable ‘knrp’ [-Wunused-variable]
array_tlp.hpp:872:12: warning: unused variable ‘knr_’ [-Wunused-variable]
array_tlp.hpp:883:12: warning: unused variable ‘knlp’ [-Wunused-variable]
In file included from array_long.cpp:28:0:
array_tlp.hpp: At global scope:
array_tlp.hpp: In instantiation of ‘A fSubArrayc(const A&, const char&) [with A = KN_<long int>]’:
array_tlp.hpp:887:6:   instantiated from ‘void ArrayOperator() [with K = long int, Z = long int]’
array_long.cpp:135:31:   instantiated from here
array_tlp.hpp:229:3: warning: unused parameter ‘b’ [-Wunused-parameter]
array_tlp.hpp: In instantiation of ‘A fSubArrayc(const A&, const char&) [with A = KN<long int>*]’:
array_tlp.hpp:890:6:   instantiated from ‘void ArrayOperator() [with K = long int, Z = long int]’
array_long.cpp:135:31:   instantiated from here
array_tlp.hpp:229:3: warning: unused parameter ‘b’ [-Wunused-parameter]
In file included from array_tlp.hpp:40:0,
                 from array_long.cpp:28:
../femlib/RNM.hpp: In member function ‘void KNM<R>::resize(long int, long int) [with R = long int]’:
array_resize.hpp:23:3:   instantiated from ‘T* resize2(const Resize<T>&, const long int&, const long int&) [with T = KNM<long int>]’
array_tlp.hpp:954:6:   instantiated from ‘void ArrayOperator() [with K = long int, Z = long int]’
array_long.cpp:135:31:   instantiated from here
../femlib/RNM.hpp:1203:10: warning: unused variable ‘lso’ [-Wunused-variable]
In file included from array_tlp.hpp:42:0,
                 from array_long.cpp:28:
Operator.hpp: At global scope:
Operator.hpp: In instantiation of ‘static R* Op3_p<R, A, B, C>::f(Stack, const A&, const B&, const C&) [with R = if_arth_KN_<long int>, A = KN_<long int>, B = KN_<long int>, C = KN_<long int>, Stack = void*]’:
AFunction.hpp:2127:69:   instantiated from ‘AnyType OneTernaryOperator3<T>::Op::operator()(Stack) const [with T = Op3_p<if_arth_KN_<long int>, KN_<long int>, KN_<long int>, KN_<long int> >, AnyType = AnyTypeWithOutCheck, Stack = void*]’
array_long.cpp:167:1:   instantiated from here
Operator.hpp:585:13: warning: unused parameter ‘s’ [-Wunused-parameter]
In file included from array_long.cpp:28:0:
array_tlp.hpp: In static member function ‘static if_arth_KN_<R>* Op3_pacc<K>::f(Stack, const KN_<R>&, const K&, const K&) [with K = long int, Stack = void*]’:
AFunction.hpp:2127:69:   instantiated from ‘AnyType OneTernaryOperator3<T>::Op::operator()(Stack) const [with T = Op3_pacc<long int>, AnyType = AnyTypeWithOutCheck, Stack = void*]’
array_long.cpp:167:1:   instantiated from here
array_tlp.hpp:758:4: warning: unused variable ‘cc’ [-Wunused-variable]
array_tlp.hpp:758:10: warning: unused variable ‘bb’ [-Wunused-variable]
array_tlp.hpp: At global scope:
array_tlp.hpp: In instantiation of ‘static SetArray<R> SetArray3<K>::f(Stack, const K&, const K&, const K&) [with K = long int, Stack = void*]’:
AFunction.hpp:2127:69:   instantiated from ‘AnyType OneTernaryOperator3<T>::Op::operator()(Stack) const [with T = SetArray3<long int>, AnyType = AnyTypeWithOutCheck, Stack = void*]’
array_long.cpp:167:1:   instantiated from here
array_tlp.hpp:779:22: warning: unused parameter ‘s’ [-Wunused-parameter]
In file included from array_tlp.hpp:40:0,
                 from array_long.cpp:28:
../femlib/RNM.hpp: In constructor ‘SetArray<R>::SetArray(long int, R, R) [with R = long int]’:
array_tlp.hpp:775:29:   instantiated from ‘static SetArray<R> SetArray2<K>::f(const K&, const K&) [with K = long int]’
AFunction.hpp:2253:85:   instantiated from ‘AnyType OneBinaryOperator<C, MI, MIx>::Op::operator()(Stack) const [with C = SetArray2<long int>, MI = OneBinaryOperatorMI, MIx = evalE_F2, AnyType = AnyTypeWithOutCheck, Stack = void*]’
array_long.cpp:167:1:   instantiated from here
../femlib/RNM.hpp:366:10: warning: ‘SetArray<long int>::n’ will be initialized after [-Wreorder]
../femlib/RNM.hpp:365:9: warning:   ‘long int SetArray<long int>::step’ [-Wreorder]
../femlib/RNM.hpp:367:14: warning:   when initialized here [-Wreorder]
array_long.cpp: In member function ‘AnyType OneBinaryOperator<C, MI, MIx>::Opt::operator()(Stack) const [with C = set_AI_B<long int, long int, affectation<long int> >, MI = OneBinaryOperatorMI, MIx = evalE_F2, AnyType = AnyTypeWithOutCheck, Stack = void*]’:
array_long.cpp:167:1: internal compiler error: Σφάλμα κατάτμησης (segmentation fault)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.6/README.Bugs> for instructions.
Comment 1 Jonathan Wakely 2011-06-01 23:25:53 UTC
(In reply to comment #0)
> Please submit a full bug report,
> with preprocessed source if appropriate.
> See <file:///usr/share/doc/gcc-4.6/README.Bugs> for instructions.

Or see http://gcc.gnu.org/bugs/
Comment 2 Dimitris Eftaxiopoulos 2011-06-02 11:30:52 UTC
(In reply to comment #1)
> (In reply to comment #0)
> > Please submit a full bug report,
> > with preprocessed source if appropriate.
> > See <file:///usr/share/doc/gcc-4.6/README.Bugs> for instructions.
> 
> Or see http://gcc.gnu.org/bugs/

The preprocessed file array_long.ii can be found at

http://anonscm.debian.org/gitweb/?p=debian-science/packages/freefempp.git;a=blob_plain;f=debian/array_long.ii;hb=b39d279840aaa88de8b8280b8bb2e3e618056d80

since it was larger than 1MB and could not be attached.
Comment 3 Jonathan Wakely 2011-06-02 11:43:31 UTC
http://www.gnu.org/software/gzip/
Comment 4 Dimitris Eftaxiopoulos 2011-06-02 11:49:36 UTC
Created attachment 24415 [details]
Preprocessed file that triggers the bug
Comment 5 Jakub Jelinek 2011-06-02 13:21:01 UTC
Reducing...
Comment 6 Jakub Jelinek 2011-06-02 14:45:15 UTC
Created attachment 24417 [details]
pr49264.ii

Partially reduced testcase.
Comment 7 Jakub Jelinek 2011-06-02 14:50:25 UTC
Caused by http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=161655
Comment 8 Jakub Jelinek 2011-06-02 15:18:54 UTC
Seems we have memcpy (&any, &D.2892, 1) and fold_stmt_1 it.
Folding turns this into MEM_REF[&any] = MEM_REF[&D.2892], which
gimplify_and_update_call_from_tree tries to regimplify, but as any seems to be
an empty class, cp_gimplify_expr optimizes that away, so we end up with no statements at all, and fold_stmt_1 is kind of unprepared to see a statement folded into nothing.
Comment 9 Jakub Jelinek 2011-06-03 06:50:50 UTC
Reduced testcase:
// PR c++/49264
// { dg-do compile }
// { dg-options "-O2" }

struct B { };
struct A { char a[sizeof (B) + 1]; } a;

static inline void
foo (const B &b)
{
  __builtin_memcpy (&a, &b, sizeof (b));
}

void
bar ()
{
  B c;
  foo (c);
}
Comment 10 Jakub Jelinek 2011-06-03 07:47:11 UTC
Created attachment 24421 [details]
gcc46-pr49264.patch

Untested fix.
Comment 11 Jakub Jelinek 2011-06-06 17:12:29 UTC
Author: jakub
Date: Mon Jun  6 17:12:25 2011
New Revision: 174711

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174711
Log:
	PR c++/49264
	* gimple-fold.c (fold_stmt_1): Don't try to fold *& on the lhs
	if stmt folded into nothing.
	* tree-inline.c (fold_marked_statements): If a builtin at the
	end of a bb folded into nothing, just update cgraph edges
	and move to next bb.
	* cgraph.c (cgraph_update_edges_for_call_stmt_node): Allow new_stmt
	to be NULL.  Don't compute count and frequency if new_call is NULL.

	* g++.dg/opt/pr49264.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/opt/pr49264.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/cgraph.c
    trunk/gcc/gimple-fold.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-inline.c
Comment 12 Jakub Jelinek 2011-06-06 17:14:33 UTC
Author: jakub
Date: Mon Jun  6 17:14:31 2011
New Revision: 174712

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174712
Log:
	PR c++/49264
	* gimple-fold.c (fold_stmt_1): Don't try to fold *& on the lhs
	if stmt folded into nothing.
	* tree-inline.c (fold_marked_statements): If a builtin at the
	end of a bb folded into nothing, just update cgraph edges
	and move to next bb.
	* cgraph.c (cgraph_update_edges_for_call_stmt_node): Allow new_stmt
	to be NULL.  Don't compute count and frequency if new_call is NULL.

	* g++.dg/opt/pr49264.C: New test.

Added:
    trunk/gcc/testsuite/gcc.dg/debug/pr49294.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/dwarf2out.c
    trunk/gcc/testsuite/ChangeLog
Comment 13 Jakub Jelinek 2011-06-06 17:16:37 UTC
Author: jakub
Date: Mon Jun  6 17:16:35 2011
New Revision: 174713

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174713
Log:
	PR c++/49264
	* gimple-fold.c (fold_stmt_1): Don't try to fold *& on the lhs
	if stmt folded into nothing.
	* tree-inline.c (fold_marked_statements): If a builtin at the
	end of a bb folded into nothing, just update cgraph edges
	and move to next bb.
	* cgraph.c (cgraph_update_edges_for_call_stmt_node): Allow new_stmt
	to be NULL.  Don't compute count and frequency if new_call is NULL.

	* g++.dg/opt/pr49264.C: New test.

Added:
    branches/gcc-4_6-branch/gcc/testsuite/g++.dg/opt/pr49264.C
Modified:
    branches/gcc-4_6-branch/gcc/ChangeLog
    branches/gcc-4_6-branch/gcc/cgraph.c
    branches/gcc-4_6-branch/gcc/gimple-fold.c
    branches/gcc-4_6-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_6-branch/gcc/tree-inline.c
Comment 14 Jakub Jelinek 2011-06-06 18:01:46 UTC
Should be fixed now.