[Bug c++/102470] C++20 NTTP causes ICE

2021-09-23 Thread iDingDong at outlook dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102470

--- Comment #1 from Kun Ge  ---
I misplaced the wrong piece of codes.

the code that actually triggered the error is:

//---
#include 
#include 

struct MemAttr {
std::size_t size;
std::size_t align;
};

template  constexpr MemAttr memAttrOf = MemAttr { .size =
sizeof(T), .align = alignof(T) };

template  using AlignedStorage =
::std::aligned_storage_t;

template  using AlignedStorageFor = AlignedStorage>;
//---

[Bug c++/102470] New: C++20 NTTP causes ICE

2021-09-23 Thread iDingDong at outlook dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102470

Bug ID: 102470
   Summary: C++20 NTTP causes ICE
   Product: gcc
   Version: 11.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: iDingDong at outlook dot com
  Target Milestone: ---

GCC 11.2 reports ICE to the following piece of code:

//---
#include 

template  struct A {
A(A const&) = default;
};

template  T> struct A {
A(A const&) = default;
};
//---

Compiled with:

> gcc -std=c++20 test.cpp

The error message:

> gcc -std=c++20 test.cpp
> test.cpp: In substitution of 'template using AlignedStorage = 
> std::aligned_storage_t<((const MemAttr)attr).size, ((const 
> MemAttr)attr).align> [with MemAttr attr = memAttrOf]':
> test.cpp:13:75:   required from here
> test.cpp:11:73: internal compiler error: Segmentation fault
>11 | template  using AlignedStorage = 
> ::std::aligned_storage_t;
>   |   
>   ^~~~
> libbacktrace could not find executable to open
> Please submit a full bug report,
> with preprocessed source if appropriate.
> See  for instructions.

[Bug c++/100698] New: Error when initializing a struct member of type char[N] with short string literal

2021-05-20 Thread iDingDong at outlook dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100698

Bug ID: 100698
   Summary: Error when initializing a struct member of type
char[N] with short string literal
   Product: gcc
   Version: 11.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: iDingDong at outlook dot com
  Target Milestone: ---

//---
struct [[maybe_unused]] A {
char a[5];
};

int main() {
A x = { .a = "Hey!" }; // OK
A y = { .a = { 'H', 'i', '\0' } }; // OK
A z = { .a = "Hi" }; // error: C99 designator 'a' outside aggregate
initializer
return 0;
}
//---

Compiled with

> g++ -std=c++20 test.cpp

This error is only triggered when attempting to initialize an array of char
with a string literal of smaller size than the array was defined.

[Bug c++/98614] New: Copy ctor/assign cannot be defaulted in specialization by concept

2021-01-09 Thread iDingDong at outlook dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98614

Bug ID: 98614
   Summary: Copy ctor/assign cannot be defaulted in specialization
by concept
   Product: gcc
   Version: 10.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: iDingDong at outlook dot com
  Target Milestone: ---

GCC 10.2 rejects the following piece of code:

//---
#include 

template  struct A {
A(A const&) = default;
};

template  T> struct A {
A(A const&) = default;
};
//---

The error message:

> :8:19: error: 'A::A(const A&)' cannot be defaulted

This can be reproduced by the compiler explorer: https://godbolt.org/z/1v6nPv

I can locally reproduce this with:

> g++ -std=c++20 test.cpp

This error only occurs when trying to default a copy constructor in a partial
specialization involving concept. The workaround is to omit the `` in the
constructor/assignment's argument declarator.

PS: move constructor/assignment seems unaffected.