[Bug c++/94765] New: Floating point type template parameter

2020-04-25 Thread emmanuel.le-tr...@cnrs-orleans.fr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94765

Bug ID: 94765
   Summary: Floating point type template parameter
   Product: gcc
   Version: 10.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: emmanuel.le-tr...@cnrs-orleans.fr
  Target Milestone: ---

With C++20, non-type template parameters can now be any scalar type[0] which
include floating point types[1]. So this

template  struct S {};

should compile. The rules for type equivalence are straightforward[2]

[0] http://eel.is/c++draft/temp#param-6
[1] http://eel.is/c++draft/basic.types#9
[2] http://eel.is/c++draft/temp.type#2

[Bug c++/88355] [c++20] Placeholder non-type template argument type deduction fails with custom types

2020-01-08 Thread emmanuel.le-tr...@cnrs-orleans.fr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88355

--- Comment #3 from Emmanuel Le Trong  ---
This bug has disappeared, both tests above compile with version 10.0.0
20200108.

[Bug c++/88395] ICE: Segmentation fault signal terminated program cc1plus, with -std=c++2a -fconcepts

2018-12-13 Thread emmanuel.le-tr...@cnrs-orleans.fr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88395

--- Comment #2 from Emmanuel Le Trong  ---
(In reply to Nicholas Krause from comment #1)
> First off that's just a valid snippet without a class definition so I was
> unable to build it against gcc itself to even check this is a bug. Further
> more can you check this is still happening and if so just report back with
> the exact code that builds but is giving you a segfault on the trunk branch.

I'm sorry I don't understand your requests. The compilation of this small piece
of code causes the compiler (trunk 20181213) to crash, without further
information.

[Bug c++/88355] [c++20] Placeholder non-type template argument type deduction fails with custom types

2019-03-01 Thread emmanuel.le-tr...@cnrs-orleans.fr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88355

--- Comment #2 from Emmanuel Le Trong  ---
Ok I got this new snippet showing what is very probably the same bug, although
the diagnostic message is not the same at all. (And quite frankly I don't
understand it.)


$ cat bug_5.cpp 
struct T {};

template  
struct U {};

template  
void f (U) {}

int main ()
{
constexpr T t;
f (U{});
}


$ g++-9 -std=c++2a -Wall -Wextra bug_5.cpp  
bug_5.cpp: In function ‘int main()’:
bug_5.cpp:12:18: error: no matching function for call to ‘f(U)’
   12 | f (U{});
  |  ^
bug_5.cpp:7:10: note: candidate: ‘template void
f(U<((T*)(void)0)->T::__ct_comp (((const T)t))>)’
7 | void f (U) {}
  |  ^
bug_5.cpp:7:10: note:   template argument deduction/substitution failed:
bug_5.cpp:12:18: note:   couldn't deduce template parameter ‘t’
   12 | f (U{});
  |  ^


$ g++-9 --verbose   
Using built-in specs.
COLLECT_GCC=g++-9
COLLECT_LTO_WRAPPER=/home/manu/system/opt/gcc-9/libexec/gcc/x86_64-pc-linux-gnu/9.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-9/configure --prefix=/home/manu/system/opt/gcc-9
--program-suffix=-9 : (reconfigured) ../gcc-9/configure
--prefix=/home/manu/system/opt/gcc-9 --program-suffix=-9 : (reconfigured)
../gcc-9/configure --prefix=/home/manu/system/opt/gcc-9 --program-suffix=-9
--enable-languages=c,c++,fortran,lto,objc --no-create --no-recursion
Thread model: posix
gcc version 9.0.1 20190227 (experimental) (GCC)

[Bug c++/88216] New: ICE (-std=c++2a) in cxx_eval_constant_expression, at cp/constexpr.c:4602

2018-11-27 Thread emmanuel.le-tr...@cnrs-orleans.fr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88216

Bug ID: 88216
   Summary: ICE (-std=c++2a) in cxx_eval_constant_expression, at
cp/constexpr.c:4602
   Product: gcc
   Version: 9.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: emmanuel.le-tr...@cnrs-orleans.fr
  Target Milestone: ---

$ g++-9 -v  
Using built-in specs.
COLLECT_GCC=g++-9
COLLECT_LTO_WRAPPER=/home/manu/system/opt/gcc-9/libexec/gcc/x86_64-pc-linux-gnu/9.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-9/configure --prefix=/home/manu/system/opt/gcc-9
--program-suffix=-9
Thread model: posix
gcc version 9.0.0 20181123 (experimental) (GCC) 

$ cat bug.cpp   
struct 
T {};

template 
struct 
U {};

template 
int
f (U );


$ g++-9 -std=c++2a -Wall -Wextra -c bug.cpp 
bug.cpp:10:8: internal compiler error: in cxx_eval_constant_expression, at
cp/constexpr.c:4602
   10 | f (U );
  |^
0x5ee04a cxx_eval_constant_expression
../../gcc-9/gcc/cp/constexpr.c:4602
0x8759b6 cxx_eval_call_expression
../../gcc-9/gcc/cp/constexpr.c:1511
0x877af8 cxx_eval_constant_expression
../../gcc-9/gcc/cp/constexpr.c:4296
0x87cf3e cxx_eval_outermost_constant_expr
../../gcc-9/gcc/cp/constexpr.c:5032
0x9a9f03 get_template_parm_object
../../gcc-9/gcc/cp/pt.c:6665
0x9a9f03 convert_nontype_argument
../../gcc-9/gcc/cp/pt.c:7126
0x9a9f03 convert_template_argument
../../gcc-9/gcc/cp/pt.c:8033
0x9a9f03 convert_template_argument
../../gcc-9/gcc/cp/pt.c:7784
0x995793 coerce_template_parms
../../gcc-9/gcc/cp/pt.c:8509
0x9a115e lookup_template_class_1
../../gcc-9/gcc/cp/pt.c:9325
0x9a115e lookup_template_class(tree_node*, tree_node*, tree_node*, tree_node*,
int, int)
../../gcc-9/gcc/cp/pt.c:9684
0x9d29db finish_template_type(tree_node*, tree_node*, int)
../../gcc-9/gcc/cp/semantics.c:3247
0x950295 cp_parser_template_id
../../gcc-9/gcc/cp/parser.c:16295
0x950406 cp_parser_class_name
../../gcc-9/gcc/cp/parser.c:22858
0x95376b cp_parser_qualifying_entity
../../gcc-9/gcc/cp/parser.c:6644
0x95376b cp_parser_nested_name_specifier_opt
../../gcc-9/gcc/cp/parser.c:6330
0x950b78 cp_parser_simple_type_specifier
../../gcc-9/gcc/cp/parser.c:17634
0x947be5 cp_parser_type_specifier
../../gcc-9/gcc/cp/parser.c:17307
0x948a8e cp_parser_decl_specifier_seq
../../gcc-9/gcc/cp/parser.c:13961
0x9618b0 cp_parser_parameter_declaration
../../gcc-9/gcc/cp/parser.c:21973
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++/88216] [9 Regression] ICE (-std=c++2a) in cxx_eval_constant_expression, at cp/constexpr.c:4602

2018-11-27 Thread emmanuel.le-tr...@cnrs-orleans.fr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88216

--- Comment #2 from emmanuel.le-tr...@cnrs-orleans.fr ---
Valid. This snippet compiles:


struct 
T {};

template 
struct 
U {};

T t;

U  u;

[Bug c++/88355] New: [c++20] Placeholder non-type template argument type deduction fails with custom types

2018-12-04 Thread emmanuel.le-tr...@cnrs-orleans.fr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88355

Bug ID: 88355
   Summary: [c++20] Placeholder non-type template argument type
deduction fails with custom types
   Product: gcc
   Version: 9.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: emmanuel.le-tr...@cnrs-orleans.fr
  Target Milestone: ---

Deducing the type of a non-type template parameter containing a placeholder
fails with custom types. 

$ g++-9 -v  
Using built-in specs.
COLLECT_GCC=g++-9
COLLECT_LTO_WRAPPER=/home/manu/system/opt/gcc-9/libexec/gcc/x86_64-pc-linux-gnu/9.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-9/configure --prefix=/home/manu/system/opt/gcc-9
--program-suffix=-9 : (reconfigured) ../gcc-9/configure
--prefix=/home/manu/system/opt/gcc-9 --program-suffix=-9
Thread model: posix
gcc version 9.0.0 20181127 (experimental) (GCC)

$ cat bug_2.cpp
#include  // for std::is_same_v

struct T {};

template 
struct U {};

template  
void f (U ) {}

int main ()
{
constexpr T t;
f(U<1>{});  // OK
f (U{});  // OK
// This works: 
auto x = t;
static_assert (std::is_same_v ); // OK
// This should work as well, as per [temp.arg.nontype], see below
f(U{});  // Error
}

$ g++-9 -std=c++2a -Wall -Wextrabug_2.cpp   -o bug_2
bug_2.cpp: In function ‘int main()’:
bug_2.cpp:20:21: error: no matching function for call to ‘f(U)’
   20 | f(U{});  // Error
  | ^
bug_2.cpp:9:10: note: candidate: ‘template void f(U)’
9 | void f (U ) {}
  |  ^
bug_2.cpp:9:10: note:   template argument deduction/substitution failed:
bug_2.cpp:20:21: note:   mismatched types ‘T’ and ‘const T’
   20 | f(U{});  // Error
  | ^
make: *** [: bug_2] Error 1


The standardese in the latest draft is:

---8<---

12.3.2 Template non-type arguments [temp.arg.nontype]
If the type T of a template-parameter (12.1) contains a placeholder type
(9.1.7.5) or a placeholder for a deduced class type (9.1.7.6), the type of the
parameter is the type deduced for the variable x in the invented declaration

T x = template-argument ;

--->8---

[Bug c++/88092] class nontype template deduction failed when providing type to class

2018-12-05 Thread emmanuel.le-tr...@cnrs-orleans.fr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88092

emmanuel.le-tr...@cnrs-orleans.fr changed:

   What|Removed |Added

 CC||emmanuel.le-trong@cnrs-orle
   ||ans.fr

--- Comment #3 from emmanuel.le-tr...@cnrs-orleans.fr ---
I have a problem with this. AFAIK, nowhere in the standard is written that a
class template without argument (i.e. not a type!) can be used as the type of a
non-type template argument. [temp.param] §4 says

> A non-type template-parameter shall have one of the following (optionally 
> cv-qualified) types:
>  — a type that is literal, has strong structural equality (10.10.1), has no 
> mutable or volatile subobjects, and in which if there is a defaulted member 
> operator<=>, then it is declared public,
>  — an lvalue reference type,
>  — a type that contains a placeholder type (9.1.7.5), or
>  — a placeholder for a deduced class type (9.1.7.6).

So 

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

should not be valid IMO.

[Bug c++/88373] New: parse error in template argument list when using bitwise not with -std=c++2a switch

2018-12-05 Thread emmanuel.le-tr...@cnrs-orleans.fr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88373

Bug ID: 88373
   Summary: parse error in template argument list when using
bitwise not with -std=c++2a switch
   Product: gcc
   Version: 9.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: emmanuel.le-tr...@cnrs-orleans.fr
  Target Milestone: ---

Using the bitwise not in a non-type template argument produces a parse error
with the -std=c++2a switch on. It works fine without the switch. It also works
with the switch on in version 8.2.1.

$ cat bug_3.cpp 
template 
constexpr T value = T {};

template 
struct S {};

using U = S >;

$ g++-9 -c bug_3.cpp && echo OK
   
  OK

$ g++-9 -c -std=c++2a bug_3.cpp 
bug_3.cpp:7:15: error: parse error in template argument list
7 | using U = S >;
  |   ^


g++-9 -v
Using built-in specs.
COLLECT_GCC=g++-9
COLLECT_LTO_WRAPPER=/home/manu/system/opt/gcc-9/libexec/gcc/x86_64-pc-linux-gnu/9.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-9/configure --prefix=/home/manu/system/opt/gcc-9
--program-suffix=-9
Thread model: posix
gcc version 9.0.0 20181204 (experimental) (GCC)

[Bug c++/88395] New: ICE: Segmentation fault signal terminated program cc1plus, with -std=c++2a -fconcepts

2018-12-06 Thread emmanuel.le-tr...@cnrs-orleans.fr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88395

Bug ID: 88395
   Summary: ICE: Segmentation fault signal terminated program
cc1plus, with -std=c++2a -fconcepts
   Product: gcc
   Version: 9.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: emmanuel.le-tr...@cnrs-orleans.fr
  Target Milestone: ---

Both trunk and 8.2.1 segfault on this valid snippet

$ cat bug_4.cpp
template 
concept bool Concept2 = requires (T t, U u)
{
{ t += u } -> T&;
};

template 
concept bool Concept = Concept2 ;

struct S
{
template 
constexpr S& operator += (T o);
};
constexpr S operator * (S a, S b)
{
return a += b;
}



$ g++-9 -std=c++2a -fconcepts -c bug_4.cpp
g++-9: internal compiler error: Segmentation fault signal terminated program
cc1plus
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://gcc.gnu.org/bugs/> for instructions.

$ g++-9 -v
Using built-in specs.
COLLECT_GCC=g++-9
COLLECT_LTO_WRAPPER=/home/manu/system/opt/gcc-9/libexec/gcc/x86_64-pc-linux-gnu/9.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-9/configure --prefix=/home/manu/system/opt/gcc-9
--program-suffix=-9
Thread model: posix
gcc version 9.0.0 20181204 (experimental) (GCC)