[Bug c++/84001] New: ICE in dependent_type_p cp/pt.c:23567 when using member type of template parameter in template list

2018-01-23 Thread profclonk at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84001

Bug ID: 84001
   Summary: ICE in dependent_type_p cp/pt.c:23567 when using
member type of template parameter in template list
   Product: gcc
   Version: 7.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: profclonk at gmail dot com
  Target Milestone: ---

Compiling this C++98 code:

struct X {
typedef int Obj;
};

template 
struct Y {};

template 
void foo (A a, Y) {  }

int main () {
X x;
Y<42> y;
foo (x, y);
}

yields an internal compiler error:

test4.cc: In substitution of ‘template void foo(A,
Y) [with A = X; typename A::Obj I = ]’:
test4.cc:14:11:   required from here
test4.cc:14:11: internal compiler error: in dependent_type_p, at cp/pt.c:23567
  foo (x, y);
   ^
0x5dc6bc dependent_type_p(tree_node*)
../../src/gcc/cp/pt.c:23567
0x5dd0b0 dependent_scope_p(tree_node*)
../../src/gcc/cp/pt.c:23598
0x5cffd7 make_typename_type(tree_node*, tree_node*, tag_types, int)
../../src/gcc/cp/decl.c:3784
0x5e4280 tsubst(tree_node*, tree_node*, int, tree_node*)
../../src/gcc/cp/pt.c:14066
0x5e1f1f unify
../../src/gcc/cp/pt.c:20659
0x5e1508 unify
../../src/gcc/cp/pt.c:20851
0x57f7db try_class_unification
../../src/gcc/cp/pt.c:19872
0x5e1e00 unify
../../src/gcc/cp/pt.c:20888
0x5f36e1 unify_one_argument
../../src/gcc/cp/pt.c:19128
0x5f8726 type_unification_real
../../src/gcc/cp/pt.c:19248
0x5fc75e fn_type_unification(tree_node*, tree_node*, tree_node*, tree_node*
const*, unsigned int, tree_node*, unification_kind_t, int, bool, bool)
../../src/gcc/cp/pt.c:18633
0x5ae5f7 add_template_candidate_real
../../src/gcc/cp/call.c:3170
0x5a6034 add_template_candidate
../../src/gcc/cp/call.c:3252
0x5a6034 add_candidates
../../src/gcc/cp/call.c:5483
0x5b04b1 perform_overload_resolution
../../src/gcc/cp/call.c:4143
0x5b059e build_new_function_call(tree_node*, vec**, bool, int)
../../src/gcc/cp/call.c:4232
0x6906f1 finish_call_expr(tree_node*, vec**, bool,
bool, int)
../../src/gcc/cp/semantics.c:2454
0x643c2c cp_parser_postfix_expression
../../src/gcc/cp/parser.c:6997
0x64455d cp_parser_unary_expression
../../src/gcc/cp/parser.c:8108
0x645303 cp_parser_cast_expression
../../src/gcc/cp/parser.c:8786

GCC Version information:

$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
7.2.0-1ubuntu1~16.04' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr
--with-gcc-major-version-only --program-suffix=-7
--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 --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 7.2.0 (Ubuntu 7.2.0-1ubuntu1~16.04) 

The problem exists at least since version 4.4.7 and also on 7.2.1 as tested on
godbolt.org. The system is x86-64 on Linux Mint (Ubuntu). The command line is:
g++ test4.cc
As no preprocessor directives were used, the preprocessed output is identical
to the shown source code. The code works on Clang.

[Bug c++/100538] New: g++ miscompile / ICE with variadic member function pointer argument list

2021-05-11 Thread profclonk at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100538

Bug ID: 100538
   Summary: g++ miscompile / ICE with variadic member function
pointer argument list
   Product: gcc
   Version: 11.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: profclonk at gmail dot com
  Target Milestone: ---

Created attachment 50792
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50792&action=edit
Source code triggering the GCC bug

Dear GCC team,

the attached code passes member function pointers to a template function. The
code should print "bar" once, but doesn't (miscompile). When commenting out
line 19 and enabling line 22 I get an internal compiler error:

: In instantiation of 'void foo(MemPtrList) [with
SubPtrTypes = int; SubPtrTypes X::* ...SubRefs = {&X::a}]':
:26:6:   required from here
:22:9: internal compiler error: in finish_expr_stmt, at
cp/semantics.c:860
   22 | (bar (), ...);
  | ^
0x1780bf9 internal_error(char const*, ...)
???:0
0x677e40 fancy_abort(char const*, int, char const*)
???:0
0x80362c finish_expr_stmt(tree_node*)
???:0
0x7dcec3 instantiate_decl(tree_node*, bool, bool)
???:0
0x7f7aab instantiate_pending_templates(int)
???:0
0x708f4d c_parse_final_cleanups()
???:0
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
ASM generation compiler returned: 1

The error happens on x86-64 Windows 10 when using MinGW-w64 via MSYS2, and also
on Compiler Explorer ( https://godbolt.org/z/vhPqKaqeW ,
https://godbolt.org/z/feP5GPdP4 ). It works fine in Clang.

Thanks,
Niklas