Bug 56518 - Segmentation fault
Summary: Segmentation fault
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.6.3
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-03-04 11:08 UTC by Elisey Zanko
Modified: 2013-03-04 12:52 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work: 4.7.0, 4.8.0
Known to fail: 4.6.4
Last reconfirmed:


Attachments
A preprocessed file causing bug (572 bytes, text/plain)
2013-03-04 11:10 UTC, Elisey Zanko
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Elisey Zanko 2013-03-04 11:08:30 UTC
Using built-in specs.
COLLECT_GCC=/usr/x86_64-pc-linux-gnu/gcc-bin/4.6.3/gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/4.6.3/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /var/tmp/portage/sys-devel/gcc-4.6.3/work/gcc-4.6.3/configure --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.6.3 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.6.3 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.6.3/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.6.3/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/include/g++-v4 --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec --disable-fixed-point --without-ppl --without-cloog --enable-lto --enable-nls --without-included-gettext --with-system-zlib --enable-obsolete --disable-werror --enable-secureplt --disable-multilib --enable-libmudflap --disable-libssp --enable-libgomp --with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/4.6.3/python --enable-checking=release --disable-libgcj --enable-libstdcxx-time --enable-languages=c,c++,fortran --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-targets=all --with-bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo 4.6.3 p1.11, pie-0.5.2'
Thread model: posix
gcc version 4.6.3 (Gentoo 4.6.3 p1.11, pie-0.5.2)
COLLECT_GCC_OPTIONS='-std=c++0x' '-save-temps' '-v' '-o' 'test' '-mtune=generic' '-march=x86-64'
 /usr/libexec/gcc/x86_64-pc-linux-gnu/4.6.3/cc1plus -E -quiet -v -D_GNU_SOURCE test.cpp -mtune=generic -march=x86-64 -std=c++0x -fpch-preprocess -o test.ii
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/../../../../x86_64-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/include/g++-v4
 /usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/include/g++-v4/x86_64-pc-linux-gnu
 /usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/include/g++-v4/backward
 /usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/include
 /usr/lib/gcc/x86_64-pc-linux-gnu/4.6.3/include-fixed
 /usr/include
End of search list.
COLLECT_GCC_OPTIONS='-std=c++0x' '-save-temps' '-v' '-o' 'test' '-mtune=generic' '-march=x86-64'
 /usr/libexec/gcc/x86_64-pc-linux-gnu/4.6.3/cc1plus -fpreprocessed test.ii -quiet -dumpbase test.cpp -mtune=generic -march=x86-64 -auxbase test -std=c++0x -version -o test.s
GNU C++ (Gentoo 4.6.3 p1.11, pie-0.5.2) version 4.6.3 (x86_64-pc-linux-gnu)
        compiled by GNU C version 4.6.3, GMP version 5.1.0, MPFR version 3.1.1-p2, MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU C++ (Gentoo 4.6.3 p1.11, pie-0.5.2) version 4.6.3 (x86_64-pc-linux-gnu)
        compiled by GNU C version 4.6.3, GMP version 5.1.0, MPFR version 3.1.1-p2, MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 64306da8006a5416135a72df2a9600e1
test.cpp: In function ‘int main(int, char**)’:
test.cpp:9:36: internal compiler error: Segmentation fault
Comment 1 Elisey Zanko 2013-03-04 11:10:09 UTC
Created attachment 29579 [details]
A preprocessed file causing bug
Comment 2 Paolo Carlini 2013-03-04 11:20:01 UTC
Both 4.7 and mainline are fine.
Comment 3 Richard Biener 2013-03-04 12:52:43 UTC
The ICE is

#0  0x00000000007bafa2 in c_common_signed_or_unsigned_type (unsignedp=1, 
    type=0x0)
    at /space/rguenther/src/svn/gcc-4_6-branch/gcc/c-family/c-common.c:3018
#1  0x00000000007bfe47 in shorten_compare (op0_ptr=0x7fffffffcb80, 
    op1_ptr=0x7fffffffcb78, restype_ptr=0x7fffffffcb70, 
    rescode_ptr=0x7fffffffcb6c)
    at /space/rguenther/src/svn/gcc-4_6-branch/gcc/c-family/c-common.c:3567

3562      else if (unsignedp0 == unsignedp1 && real1 == real2
3563               && TYPE_PRECISION (TREE_TYPE (primop0)) < TYPE_PRECISION (*restype_ptr)
3564               && TYPE_PRECISION (TREE_TYPE (primop1)) < TYPE_PRECISION (*restype_ptr))
3565        {
3566          type = common_type (TREE_TYPE (primop0), TREE_TYPE (primop1));
3567          type = c_common_signed_or_unsigned_type (unsignedp0
3568                                                   || TYPE_UNSIGNED (*restype_ptr),
3569                                                   type);

which ends up calling cp_common_type which has (still also on trunk):

static tree
cp_common_type (tree t1, tree t2)
{
...
  if (SCOPED_ENUM_P (t1) || SCOPED_ENUM_P (t2))
    {
      if (TYPE_MAIN_VARIANT (t1) == TYPE_MAIN_VARIANT (t2))
        return build_type_attribute_variant (t1, attributes);
      else
        return NULL_TREE;
    }

but common_type () is not expected to return NULL_TREE.

ISTR this bug, it got fixed for 4.7+.