[Bug c++/81866] [8 Regression] ICE with a default template parameter which is a template class nested in a template class

2021-03-04 Thread soko.slav at yandex dot ru via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81866

--- Comment #9 from Sokolov Viacheslav  ---
Looks like it is fixed on trunk along with
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96474

[Bug c++/81866] [8 Regression] ICE with a default template parameter which is a template class nested in a template class

2021-02-11 Thread soko.slav at yandex dot ru via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81866

--- Comment #8 from Sokolov Viacheslav  ---
looks like the following is the same bug: https://godbolt.org/z/1vTqs3

template 
struct A
{
template 
struct B
{
};
};

A<>::B b;

results in (on trunk)


: In substitution of 'template B()-> A<>::B<
 > [with  = void]':
:10:8:   required from here
:5:12: internal compiler error: in retrieve_specialization, at
cp/pt.c:1248
5 | struct B
  |^
0x1ce8359 internal_error(char const*, ...)
???:0
0x6b702d fancy_abort(char const*, int, char const*)
???:0
0x91364f tsubst(tree_node*, tree_node*, int, tree_node*)
???:0
0x9498ff instantiate_template(tree_node*, tree_node*, int)
???:0
0x9513f6 fn_type_unification(tree_node*, tree_node*, tree_node*, tree_node*
const*, unsigned int, tree_node*, unification_kind_t, int, conversion**, bool,
bool)
???:0
0x6de832 build_new_function_call(tree_node*, vec**, int)
???:0
0x906642 do_auto_deduction(tree_node*, tree_node*, tree_node*, int,
auto_deduction_context, tree_node*, int)
???:0
0x7b05d4 cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int)
???:0
0x8de81d c_parse_file()
???:0
0xa5c452 c_common_parse_file()
???:0
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See  for instructions.
Compiler returned: 1

[Bug c++/96474] Internal compiler error with template struct inside template struct

2021-02-11 Thread soko.slav at yandex dot ru via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96474

Sokolov Viacheslav  changed:

   What|Removed |Added

 CC||soko.slav at yandex dot ru

--- Comment #3 from Sokolov Viacheslav  ---
Looks like the following is the same bug: https://godbolt.org/z/YzEh3Y

template 
struct A
{
template 
struct B
{
};
};

A<>::B b;

results in (on trunk)

: In substitution of 'template B()-> A<>::B<
 > [with  = void]':
:10:8:   required from here
:5:12: internal compiler error: in retrieve_specialization, at
cp/pt.c:1248
5 | struct B
  |^
0x1ce8359 internal_error(char const*, ...)
???:0
0x6b702d fancy_abort(char const*, int, char const*)
???:0
0x91364f tsubst(tree_node*, tree_node*, int, tree_node*)
???:0
0x9498ff instantiate_template(tree_node*, tree_node*, int)
???:0
0x9513f6 fn_type_unification(tree_node*, tree_node*, tree_node*, tree_node*
const*, unsigned int, tree_node*, unification_kind_t, int, conversion**, bool,
bool)
???:0
0x6de832 build_new_function_call(tree_node*, vec**, int)
???:0
0x906642 do_auto_deduction(tree_node*, tree_node*, tree_node*, int,
auto_deduction_context, tree_node*, int)
???:0
0x7b05d4 cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int)
???:0
0x8de81d c_parse_file()
???:0
0xa5c452 c_common_parse_file()
???: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.
Compiler returned: 1

[Bug c++/94517] New: incorrect use of enable_if compiles but should not

2020-04-07 Thread soko.slav at yandex dot ru
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94517

Bug ID: 94517
   Summary: incorrect use of enable_if compiles but should not
   Product: gcc
   Version: 10.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: soko.slav at yandex dot ru
  Target Milestone: ---

Following code https://godbolt.org/z/Zfazdt
compiles with GCC
and does not compile (as expected) if the class becomes a template:
https://godbolt.org/z/2KRRin

It should not compile in the first case either because there is no template
parameter being deduced.

Sources:

#include 

struct NoDefault
{
NoDefault() = delete;
};

// compiles while should not
struct X : public NoDefault
{
template 
<
std::enable_if_t
<   
std::is_default_constructible_v
<
NoDefault
>
>* = nullptr
> X() : NoDefault{}
{
}
};

template 
struct Y : public NoDefault
{
template 
<
std::enable_if_t
<   
std::is_default_constructible_v
<
NoDefault
>
>* = nullptr
> Y() : NoDefault{}
{
}
};

// expectedly does not compile
template struct Y;

[Bug c++/92912] New: Bad diagnostic for capture of this in free function

2019-12-11 Thread soko.slav at yandex dot ru
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92912

Bug ID: 92912
   Summary: Bad diagnostic for capture of this in free function
   Product: gcc
   Version: 10.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: soko.slav at yandex dot ru
  Target Milestone: ---

This free function

void foo()
{
[&]()
{
static_cast(this);
};
}

does not compile but the message is misleading:

error: 'this' was not captured for this lambda function
static_cast(this);

Actually 'this' cannot be captured here as 'this' is keyword which cannot be
used in this context.

Expected message:
error: invalid use of 'this' in non-member function

tested locally and on https://godbolt.org/z/5cAA3k (more examples there
including similar case without lambda)

[Bug c++/92911] New: Valid lambda inside variadic template does not compile (2)

2019-12-11 Thread soko.slav at yandex dot ru
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92911

Bug ID: 92911
   Summary: Valid lambda inside variadic template does not compile
(2)
   Product: gcc
   Version: 10.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: soko.slav at yandex dot ru
  Target Milestone: ---

Code:

template 
void foo()
{
(
[]()
{
using T = Ts;
}(),...
);
}
template void foo<>();


fails to compile with message

In function 'void foo()':
:8:10: error: operand of fold expression has no unexpanded parameter
packs


Tested locally and on https://godbolt.org/z/KpYaup

[Bug c++/92910] New: Valid lambda inside variadic template does not compile

2019-12-11 Thread soko.slav at yandex dot ru
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92910

Bug ID: 92910
   Summary: Valid lambda inside variadic template does not compile
   Product: gcc
   Version: 7.5.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: soko.slav at yandex dot ru
  Target Milestone: ---

Code:

template 
void foo()
{
(
[]
{
static_cast(nullptr);
}()
, ...
);
}
template void foo<>();

fails to compile with message

In lambda function:
:7:13: error: parameter packs not expanded with '...':
 static_cast(nullptr);
:7:13: note: 'Ts'
: In function 'void foo()':
:8:10: error: operand of fold expression has no unexpanded parameter
packs

up to gcc-7.5 (x86-64) 
compiles on gcc-8.1 and later

Tested locally and on https://godbolt.org/z/F2jR9U

[Bug c++/92909] New: ICE on incorrect lambda inside variadic template

2019-12-11 Thread soko.slav at yandex dot ru
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92909

Bug ID: 92909
   Summary: ICE on incorrect lambda inside variadic template
   Product: gcc
   Version: 8.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: soko.slav at yandex dot ru
  Target Milestone: ---

Code:

template 
void foo()
{
[]
{
using T = Ts;
}();
}
template void foo<>();


fails to compile with message

: In lambda function:
:10:22: internal compiler error: in is_base_type, at dwarf2out.c:12893
 template void foo<>();

starting from gcc-8.1 (x86-64) till now including trunk, modules and contracts
branches
does not ICE on gcc-7.5 and earlier

does not ICE without lambda

Tested locally and on https://godbolt.org/z/gWfqhB

[Bug c++/90495] New: Incorrect parsing of a()->b construction

2019-05-15 Thread soko.slav at yandex dot ru
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90495

Bug ID: 90495
   Summary: Incorrect parsing of a()->b construction
   Product: gcc
   Version: 9.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: soko.slav at yandex dot ru
  Target Milestone: ---

Code:

struct T {
template 
int get(int v){return v;}

template 
T* getT(){return this;}

template 
int get2(){return getT()->get(5);}
};

int main() {
return T().get2<3>();
}

fails to compile with message

: In instantiation of 'int T::get2() [with int x = 3]':
:13:24:   required from here
:9:37: error: invalid operands of types '' and 'int' to binary 'operator<'
9 | int get2(){return getT()->get(5);}

starting from gcc-7.1 (x86-64) till now including trunk, modules and contracts
branches
compiles on gcc-6.3

Tested locally and on https://godbolt.org/z/IaTDBm

workarounds easily like this

int get2(){return getT()->template get(5);}

or by splitting calls into several codelines, so it actually does not affect me