[Bug c++/80840] New: ICE in convert_nontype_argument reference to double

2017-05-20 Thread cipherjason at hotmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80840

Bug ID: 80840
   Summary: ICE in convert_nontype_argument reference to double
   Product: gcc
   Version: 7.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: cipherjason at hotmail dot com
  Target Milestone: ---

The following code causes an internal compiler error:

#include 

template 
struct Just;

template 
struct Number {
static constexpr double value = X;
using result = Just;
};

int main() {}



prog.cc:9:45: internal compiler error: in convert_nontype_argument, at
cp/pt.c:6828
 using result = Just;
 ^
0x5e59bd convert_nontype_argument
../../gcc-7.1.0/gcc/cp/pt.c:6827
0x5e59bd convert_template_argument
../../gcc-7.1.0/gcc/cp/pt.c:7668
0x5e669c coerce_template_parms
../../gcc-7.1.0/gcc/cp/pt.c:8128
0x5e8a09 lookup_template_class_1
../../gcc-7.1.0/gcc/cp/pt.c:8664
0x5e8a09 lookup_template_class(tree_node*, tree_node*, tree_node*, tree_node*,
int, int)
../../gcc-7.1.0/gcc/cp/pt.c:9009
0x6827dd finish_template_type(tree_node*, tree_node*, int)
../../gcc-7.1.0/gcc/cp/semantics.c:3151
0x631ff4 cp_parser_template_id
../../gcc-7.1.0/gcc/cp/parser.c:15495
0x63214f cp_parser_class_name
../../gcc-7.1.0/gcc/cp/parser.c:21953
0x63c737 cp_parser_qualifying_entity
../../gcc-7.1.0/gcc/cp/parser.c:6286
0x63c737 cp_parser_nested_name_specifier_opt
../../gcc-7.1.0/gcc/cp/parser.c:5972
0x63f452 cp_parser_simple_type_specifier
../../gcc-7.1.0/gcc/cp/parser.c:16826
0x62828d cp_parser_type_specifier
../../gcc-7.1.0/gcc/cp/parser.c:16499
0x63e6c2 cp_parser_type_specifier_seq
../../gcc-7.1.0/gcc/cp/parser.c:20781
0x6355f1 cp_parser_type_id_1
../../gcc-7.1.0/gcc/cp/parser.c:20627
0x63bb28 cp_parser_type_id
../../gcc-7.1.0/gcc/cp/parser.c:20697
0x63bb28 cp_parser_alias_declaration
../../gcc-7.1.0/gcc/cp/parser.c:18593
0x625d3c cp_parser_member_declaration
../../gcc-7.1.0/gcc/cp/parser.c:23041
0x62696a cp_parser_member_specification_opt
../../gcc-7.1.0/gcc/cp/parser.c:22945
0x62696a cp_parser_class_specifier_1
../../gcc-7.1.0/gcc/cp/parser.c:22098
0x6285c1 cp_parser_class_specifier
../../gcc-7.1.0/gcc/cp/parser.c:22350
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.

[Bug c++/80841] New: Fails to match template specialization with polymorphic non-type template argument

2017-05-20 Thread cipherjason at hotmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80841

Bug ID: 80841
   Summary: Fails to match template specialization with
polymorphic non-type template argument
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: cipherjason at hotmail dot com
  Target Milestone: ---

This code fails to match the specialization of MaybeDestruct:

#include 

template 
struct Just;

template  class Fjust, class Maybe>
struct MaybeDestruct;

template  class Fjust, T X>
struct MaybeDestruct> {
using result = typename Fjust::result;
};

template 
struct Number {
using result = Just;
};

static constexpr double input = 2.0;
int main() {
using result = typename MaybeDestruct>::result;
}



If the use of template parameter T is stripped out then it seems to work:

#include 

template 
struct Just;

template  class Fjust, class Maybe>
struct MaybeDestruct;

template  class Fjust, const double& X>
struct MaybeDestruct> {
using result = typename Fjust::result;
};

template 
struct Number {
using result = Just;
};

static constexpr double input = 2.0;
int main() {
using result = typename MaybeDestruct>::result;
}

[Bug c++/80841] Fails to match template specialization with polymorphic non-type template argument

2017-05-22 Thread cipherjason at hotmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80841

--- Comment #2 from Jason Bell  ---
Thanks that's a good reduced example.  I've changed it slightly so it works
with constexpr input.

//#
template 
struct A {};

template 
struct B {};

template 
struct B> 
{
  using result = T;
};

static constexpr double input = 1.;

int main() {
  using result1 = typename B>::result; // OK
  using result2 = typename B>::result;
// OK
  using result3 = typename B>::result;
// Error
}
//#

I've noticed that it works in Clang if using --std=c++14 but not with
--std=c++1z (same as my previous example).

[Bug c++/80841] Fails to match template specialization with polymorphic non-type template argument

2017-05-22 Thread cipherjason at hotmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80841

--- Comment #4 from Jason Bell  ---
(In reply to Daniel Krügler from comment #3)
> (In reply to Jason Bell from comment #2)
> > Thanks that's a good reduced example.  I've changed it slightly so it works
> > with constexpr input.
> 
> But that is just adding additional complexity: The constexpr declaration is
> unnecessary when you provide an argument of reference type to a non-type
> template of reference type.

I agree that should be the case but with my GCC compiler (6.3.1) on C++14 mode
I get an error from that... "error: the value of ‘input’ is not usable in a
constant expression" even though it's used as a reference.  If I static cast it
this problem goes away, but then I get different behaviour on Clang with
C++14...  So the constexpr version seems a bit more portable for testing this
particular issue.