g++ 7.3 and g++ 8.2 report segmentation fault

Bug #1823296 reported by Alexey Kozin
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
gcc
Fix Released
Medium
gcc-7 (Ubuntu)
Confirmed
Undecided
Unassigned
gcc-8 (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

Hello,
I'm developing yet another c++ wrapper for BLAS libraries.
I've received an internal error (segmentation fault) from g++ 7.3.0-27ubuntu1~18.04 and the same error from 8.2.0-1ubuntu2~18.04.

The exact error text is:
.......
g++-8 -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"test.d" -MT"test.o" -o "test.o" "../test.cpp"
../test.cpp: In function ‘void test_shape_creator()’:
../test.cpp:19:18: internal compiler error: Ошибка сегментирования
  blaspp<1> v({14});
                  ^
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-8/README.Bugs> for instructions.
.......

Unfortunately, my code is enough complicated and probably does not have proper logic currently.

I tried to simplify the code. But I failed to do it in a reasonable time. So I changed my code to bypass the issue.
There are 2 big headers about 1000 rows each and two small cpp-files.
I've read that you do not want such files.

So, please inform me if you agree to work with my sources.

gcc info:
Using built-in specs.
COLLECT_GCC=g++-8
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 8.2.0-1ubuntu2~18.04' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-8 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 8.2.0 (Ubuntu 8.2.0-1ubuntu2~18.04)

Ubuntu:
Description: Ubuntu 18.04.2 LTS
Release: 18.04

Best regards,
Alexey

Revision history for this message
Matthias Klose (doko) wrote :

please attach the preprocessed source

Changed in gcc-7 (Ubuntu):
status: New → Incomplete
Revision history for this message
Alexey Kozin (kozin1972) wrote :

The main file. The 19-th line causes error.

Revision history for this message
Alexey Kozin (kozin1972) wrote :

The main header. The problem line numbers are 768-770.
The variadic constructor along with the constructor from plane array causes an error.
Removing one of them helps to compile successfully.

Revision history for this message
Alexey Kozin (kozin1972) wrote :

The file is included from blaspp.h

Revision history for this message
In , Matthias Klose (doko) wrote :
Download full text (4.1 KiB)

$ cat test.ii
template <int, int, bool, class> class a;
namespace b {
template <typename, unsigned long, long, unsigned long, typename...> class b;
template <unsigned long, typename> struct c;
template <typename l, unsigned long d, unsigned long dim, typename... curshape>
struct c<d, b<l, dim, 0, dim, curshape...>> {
  using e = typename c<d - 1, b<l, dim, 0, dim, a<0, 1, true, void>>>::e;
};
template <typename l, unsigned long dim, typename... curshape>
struct c<0, b<l, dim, 0, dim, curshape...>> {
  using e = b<l, dim, 0, dim, curshape...>;
};
template <typename l, unsigned long f,
          template <int, int, bool, typename> class baseclass, int g, int h,
          typename i, typename... j>
class b<l, f, 0, f, baseclass<g, h, true, i>, j...> {
  b(long);
  b(const long (&)[]);
};
} // namespace b
template <long dim, typename l = double>
using blaspp = typename b::c<dim, b::b<l, dim, 0, dim>>::e;
blaspp<1> k({4})

$ g++ -c test.ii
test.ii:23:16: internal compiler error: Segmentation fault
 blaspp<1> k({4})
                ^
0x8a0698 crash_signal
        ../../src/gcc/toplev.c:325
0x5aa51e compare_ics
        ../../src/gcc/cp/call.c:9684
0xe8cbe1 joust
        ../../src/gcc/cp/call.c:10124
0xe8a7f6 tourney
        ../../src/gcc/cp/call.c:10526
0xe8a7f6 build_new_method_call_1
        ../../src/gcc/cp/call.c:9295
0xe8a7f6 build_new_method_call(tree_node*, tree_node*, vec<tree_node*, va_gc, vl_embed>**, tree_node*, int, tree_node**, int)
        ../../src/gcc/cp/call.c:9462
0xe8a7f6 build_special_member_call(tree_node*, tree_node*, vec<tree_node*, va_gc, vl_embed>**, tree_node*, int, int)
        ../../src/gcc/cp/call.c:8989
0xede19b expand_default_init
        ../../src/gcc/cp/init.c:1906
0xede19b expand_aggr_init_1
        ../../src/gcc/cp/init.c:2021
0xede19b build_aggr_init(tree_node*, tree_node*, int, int)
        ../../src/gcc/cp/init.c:1761
0xec44b8 build_aggr_init_full_exprs
        ../../src/gcc/cp/decl.c:6292
0xec44b8 check_initializer
        ../../src/gcc/cp/decl.c:6441
0xec2cbf cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int)
        ../../src/gcc/cp/decl.c:7154
0xf03597 cp_parser_init_declarator
        ../../src/gcc/cp/parser.c:19819
0xefec29 cp_parser_simple_declaration
        ../../src/gcc/cp/parser.c:13058
0xefe415 cp_parser_block_declaration
        ../../src/gcc/cp/parser.c:12877
0xefd737 cp_parser_declaration
        ../../src/gcc/cp/parser.c:12775
0xefd54a cp_parser_declaration_seq_opt
        ../../src/gcc/cp/parser.c:12651
0x14ba85b cp_parser_translation_unit
        ../../src/gcc/cp/parser.c:4563
0x14ba85b c_parse_file()
        ../../src/gcc/cp/parser.c:39118
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.

$ g++-7 -c test.ii
test.ii:18:21: error: parameter '<anonymous>' includes reference to array of unknown bound 'const long int []'
   b(const long (&)[]);
                     ^
test.ii:23: confused by earlier errors, bailing out

$ g++-9 -c test.ii
test.ii:23:16: error: call of overloaded 'b(<brace-enclosed initializer list>)' is ambiguous
   23 | blaspp<1> k({4})
      | ^
test.ii:18:3: note: cand...

Read more...

Revision history for this message
In , Matthias Klose (doko) wrote :

works on the gcc-7 branch and the trunk, ICEs on the gcc-8-branch.

Revision history for this message
Matthias Klose (doko) wrote :

$ g++-7 -c test.ii
test.ii:18:21: error: parameter '<anonymous>' includes reference to array of unknown bound 'const long int []'
   b(const long (&)[]);
                     ^
test.ii:23: confused by earlier errors, bailing out

$ g++-9 -c test.ii
test.ii:23:16: error: call of overloaded 'b(<brace-enclosed initializer list>)' is ambiguous
   23 | blaspp<1> k({4})
      | ^
test.ii:18:3: note: candidate: 'b::b<l, f, 0, f, baseclass<g, h, true, i>, j ...>::b(const long int (&)[]) [with l = double; long unsigned int f = 1; baseclass = a; int g = 0; int h = 1; i = void; j = {}]'
   18 | b(const long (&)[]);
      | ^
test.ii:17:3: note: candidate: 'b::b<l, f, 0, f, baseclass<g, h, true, i>, j ...>::b(long int) [with l = double; long unsigned int f = 1; baseclass = a; int g = 0; int h = 1; i = void; j = {}]'
   17 | b(long);
      | ^
test.ii:16:7: note: candidate: 'constexpr b::b<double, 1, 0, 1, a<0, 1, true, void> >::b(const b::b<double, 1, 0, 1, a<0, 1, true, void> >&)'
   16 | class b<l, f, 0, f, baseclass<g, h, true, i>, j...> {
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test.ii:16:7: note: candidate: 'constexpr b::b<double, 1, 0, 1, a<0, 1, true, void> >::b(b::b<double, 1, 0, 1, a<0, 1, true, void> >&&)'
test.ii:23:16: error: expected ',' or ';' at end of input
   23 | blaspp<1> k({4})
      | ^

Changed in gcc-7 (Ubuntu):
status: Incomplete → Confirmed
Changed in gcc:
importance: Unknown → Medium
status: Unknown → New
Revision history for this message
Alexey Kozin (kozin1972) wrote :

The preprocessed source is included.
gcc -c test.ii
../test.cpp: In function ‘void test_shape_creator()’:
../test.cpp:19:18: internal compiler error: Ошибка сегментирования
  blaspp<1> v({14});
                  ^
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-7/README.Bugs> for instructions.

Revision history for this message
In , Marxin-m (marxin-m) wrote :

It's rejected on trunk since r268606.

Revision history for this message
In , Marxin-m (marxin-m) wrote :

The ICE is much older that GCC-8:

  acafca510c97652f(09 Oct 2014 07:40): [took: 2.880s] result: OK
pr89994.cc:18:21: error: parameter ‘<anonymous>’ includes reference to array of unknown bound ‘const long int []’
   b(const long (&)[]);
                     ^
pr89994.cc:23:16: internal compiler error: Segmentation fault
 blaspp<1> k({4})
                ^

Changed in gcc:
status: New → Confirmed
Alexey Kozin (kozin1972)
Changed in gcc-8 (Ubuntu):
status: New → Invalid
Revision history for this message
In , Jakub-gcc (jakub-gcc) wrote :

GCC 8.4.0 has been released, adjusting target milestone.

Revision history for this message
In , Jakub-gcc (jakub-gcc) wrote :

The GCC 8 branch is being closed, fixed in GCC 9.1.

Changed in gcc:
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.