[Bug c++/95434] New: ICE for CTAD in generic lambda within variadic lambda

2020-05-29 Thread johelegp at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95434

Bug ID: 95434
   Summary: ICE for CTAD in generic lambda within variadic lambda
   Product: gcc
   Version: 10.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
  Target Milestone: ---

The following snippet ICEs. See https://godbolt.org/z/-fZVX4.
```C++
template  struct type { T value; };
template  type(T) -> type;
void f()
{
[] class... Ts>()
{
(..., [] class T>() {
T{0};
}.template operator()());
}
.template operator()();
}

```

[Bug c++/95434] ICE for CTAD in generic lambda within variadic lambda

2020-05-29 Thread johelegp at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95434

Johel Ernesto Guerrero Peña  changed:

   What|Removed |Added

 CC||johelegp at gmail dot com

--- Comment #1 from Johel Ernesto Guerrero Peña  ---
Perhaps it's related to the following snippet that errors. I don't see why it
shouldn't work. Should I open a separate bug report on this?
```C++
template  class... Ts>
void g()
{
(..., Ts{0}); // error: operand of fold expression has no unexpanded
parameter packs
}
```

[Bug c++/95454] New: type-level nodiscard not applied to constructors

2020-05-31 Thread johelegp at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95454

Bug ID: 95454
   Summary: type-level nodiscard not applied to constructors
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
  Target Milestone: ---

The following does not warn for constructors. See https://godbolt.org/z/BTZwew.
```C++
struct [[nodiscard]] X {
int x;
X operator+() const { return *this; }
};
class [[nodiscard]] Y {
int y;
public:
Y operator+() const { return *this; }
};
void f()
{
X{};
Y{};
X x;
+x;
Y y;
+y;
}
```

[Bug c++/95486] New: ICE for alias CTAD with non-dependent argument and constrained constructor

2020-06-02 Thread johelegp at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95486

Bug ID: 95486
   Summary: ICE for alias CTAD with non-dependent argument and
constrained constructor
   Product: gcc
   Version: 10.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/cPWdGW.
```C++
template
concept Auto = true;

template
struct X { constexpr X(const Auto auto) {} };

template
using Y = X;

constexpr Y y{1};
```

[Bug c++/95486] ICE for alias CTAD with non-dependent argument and constrained constructor

2020-06-02 Thread johelegp at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95486

--- Comment #2 from Johel Ernesto Guerrero Peña  ---
That commit added the feature I'm trying to use. I'd hope it's valid, or at
least with this other constructor added: `constexpr X(U) {}`.

[Bug c++/95486] ICE for alias CTAD with non-dependent argument and constrained constructor

2020-06-02 Thread johelegp at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95486

--- Comment #3 from Johel Ernesto Guerrero Peña  ---
Having only the above unconstrained constructor works as expected, so I suppose
it's valid. See https://godbolt.org/z/nMysB_. The actual use case doesn't
currently have the unconstrained constructor, but does have a constrained
constructor and the ICE would prevent usage of the feature.

[Bug c++/95568] New: No CTAD with list initialization within requires-clause

2020-06-07 Thread johelegp at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95568

Bug ID: 95568
   Summary: No CTAD with list initialization within
requires-clause
   Product: gcc
   Version: 10.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/Ljt-85.
```C++
template struct X { T x; };
template concept Y = requires { X{0}; };
```

[Bug c++/95629] consteval operator== crashes compiler

2020-06-14 Thread johelegp at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95629

Johel Ernesto Guerrero Peña  changed:

   What|Removed |Added

 CC||johelegp at gmail dot com

--- Comment #3 from Johel Ernesto Guerrero Peña  ---
Reduced test case: https://gcc.godbolt.org/z/aT8Dv-.
```C++
struct A { int x; };
consteval A operator+(A x) { return x; }
void f() { +A(0); }
```

This one doesn't involve a constructor call within the evaluation:
https://gcc.godbolt.org/z/fJQC_M.
```C++
struct A { int x; };
consteval const A& operator+(const A& x) { return x; }
void f() { constexpr A a(0); +a; }
```

[Bug c++/95735] New: ICE on invalid non-type template argument

2020-06-17 Thread johelegp at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95735

Bug ID: 95735
   Summary: ICE on invalid non-type template argument
   Product: gcc
   Version: 10.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/v7iLPn.
```C++
template 
requires requires { F(); }
bool v{};

void f() {
int x;
static_assert(v);
}
```
: In function 'void f()':
:7:19: error: parse error in template argument list
7 | static_assert(v);
  |   ^~~~
:7:19: error: template argument 1 is invalid
:7: confused by earlier errors, bailing out
Compiler returned: 1

Less silly example: https://godbolt.org/z/-bWfJ4.
```C++
template 
requires requires { F(); }
bool v{};

void f() {
int x;
static_assert(v<[&] { x++; }>);
}
```
: In function 'void f()':
:7:19: error: 'f()::{x}' is not a
constant expression
7 | static_assert(v<[&] { x++; }>);
  |   ^~~
:7: confused by earlier errors, bailing out
Compiler returned: 1

[Bug c++/95788] New: std::ranges::construct_at's placement new not intercepted

2020-06-20 Thread johelegp at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95788

Bug ID: 95788
   Summary: std::ranges::construct_at's placement new not
intercepted
   Product: gcc
   Version: 10.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/diWS5T.
```C++
#include 

constexpr void f()
{
const int sz{1};
int* data{std::allocator{}.allocate(sz)};
std::ranges::construct_at(data, 42);
std::ranges::destroy(data, data + sz);
std::allocator{}.deallocate(data, sz);
}

constexpr int x{(f(), 0)};
```
Other stuff in `bits/ranges_uninitialized.h` may be similarly affected.

[Bug c++/95568] No CTAD with list initialization within requires-clause

2020-06-20 Thread johelegp at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95568

--- Comment #5 from Johel Ernesto Guerrero Peña  ---
(In reply to Marek Polacek from comment #2)
> The problem seems to be not that we're in a require-clause but that we're in
> a template, the following is also rejected:
> 
> template struct X { T x; };
> template void g () { X{0}; }

Then this may be related to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95434.

[Bug c++/95797] New: Can std::allocator.deallocate newed pointer during constant evaluation

2020-06-20 Thread johelegp at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95797

Bug ID: 95797
   Summary: Can std::allocator.deallocate newed pointer during
constant evaluation
   Product: gcc
   Version: 10.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/TxPbdC.
```C++
#include 
static_assert(
(std::allocator{}.deallocate(new int[1], 1),
true));
```
According to https://timsong-cpp.github.io/cppwp/n4861/allocator.members#6, the
argument "is a pointer value obtained from `allocate()`".

[Bug c++/95806] New: Result of call with reference argument to newed object is cached during constant evaluation

2020-06-21 Thread johelegp at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95806

Bug ID: 95806
   Summary: Result of call with reference argument to newed object
is cached during constant evaluation
   Product: gcc
   Version: 10.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/zzM-Qn.
```C++
#include 

constexpr bool is_zero(int& x) { return x == 0; }

constexpr void f()
{
int& x = *new int{0};
assert(is_zero(x));
x = 1;
assert(!is_zero(x));
delete &x;
}

constexpr int x{([]() consteval { f(); }(), 0)};
```

[Bug c++/95808] New: Can mismatch non-array new/delete with array new/delete during constant evaluation

2020-06-21 Thread johelegp at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95808

Bug ID: 95808
   Summary: Can mismatch non-array new/delete with array
new/delete during constant evaluation
   Product: gcc
   Version: 10.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/ZHiKmm.
```C++
constexpr void f()
{
delete[] new int;
delete new int[1];
}
constexpr int x{([]() consteval { f(); }(), 0)};
```

[Bug c++/95977] New: No deallocation of temporary in return-statement during constant evaluation

2020-06-29 Thread johelegp at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95977

Bug ID: 95977
   Summary: No deallocation of temporary in return-statement
during constant evaluation
   Product: gcc
   Version: 10.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/iyRFxf.
```C++
struct X {
int* x{new int{42}};
X() = default;
constexpr X(const X& x) : x{new int{*x.x}} { }
constexpr ~X() { delete x; }
};
constexpr int f() { X x; return *X{x}.x; }
constexpr int z{f()};
```
```
:4:45: error: 'f()' is not a constant expression because allocated
storage has not been deallocated

4 | constexpr X(const X& x) : x{new int{*x.x}} { }

  | ^
```

[Bug c++/95977] No deallocation of temporary in return-statement during constant evaluation

2020-06-29 Thread johelegp at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95977

--- Comment #1 from Johel Ernesto Guerrero Peña  ---
Slightly simplified: https://godbolt.org/z/9unpTF.
```C++
struct X {
int* x{new int{42}};
constexpr ~X() { delete x; }
};
constexpr int f() { return *X{}.x; }
constexpr int z{f()};
```

[Bug c++/96090] New: Inconsistent querying of differring exception specifications of explicitly defaulted functions

2020-07-06 Thread johelegp at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96090

Bug ID: 96090
   Summary: Inconsistent querying of differring exception
specifications of explicitly defaulted functions
   Product: gcc
   Version: 10.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/SiGMyX.
```C++
#include 
using namespace std;
struct yesthrow_t
{
yesthrow_t()  noexcept(false) = default;
yesthrow_t(const yesthrow_t&) noexcept(false) = default;
yesthrow_t(  yesthrow_t&&)noexcept(false) = default;
yesthrow_t& operator=(const yesthrow_t&)  noexcept(false) = default;
yesthrow_t& operator=(  yesthrow_t&&) noexcept(false) = default;
};
static_assert(!is_nothrow_default_constructible_v);
static_assert(!is_nothrow_copy_constructible_v<   yesthrow_t>);
static_assert(!is_nothrow_copy_assignable_v<  yesthrow_t>);
static_assert(!is_nothrow_move_constructible_v<   yesthrow_t>);
static_assert(!is_nothrow_move_assignable_v<  yesthrow_t>);
```
https://gcc.gnu.org/ml/gcc-patches/2019-09/msg00311.html calls out a single
case, but not this inconsistency.

[Bug c++/96193] New: No ADL for hidden friend in call with explicit template arguments

2020-07-14 Thread johelegp at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96193

Bug ID: 96193
   Summary: No ADL for hidden friend in call with explicit
template arguments
   Product: gcc
   Version: 10.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/qhEfGd.
```C++
struct B
{
template 
friend void f(B)
{
}
};

void g()
{
f(B{});
}
```

[Bug c++/96193] No ADL for hidden friend in call with explicit template arguments

2020-07-14 Thread johelegp at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96193

--- Comment #1 from Johel Ernesto Guerrero Peña  ---
That actually compiles if I add -std=c++20. If the call is itself dependent, it
fails to compile. See https://godbolt.org/z/KqGhKE.
```C++
template 
struct B
{
template 
friend void f(B)
{
}
};

template 
struct X
{
template 
friend void f(const X& x)
{
f(B{});
}
};

void g()
{
f(X{});
}
```

[Bug c++/96193] No ADL for hidden friend in call with explicit template arguments

2020-07-14 Thread johelegp at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96193

--- Comment #3 from Johel Ernesto Guerrero Peña  ---
Yes! I left it out expecting it to be backported as an extension like Clang
does.

[Bug d/96229] New: Invalid specialization accepted when also constrained in base template template parameter

2020-07-16 Thread johelegp at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96229

Bug ID: 96229
   Summary: Invalid specialization accepted when also constrained
in base template template parameter
   Product: gcc
   Version: 10.1.0
   URL: https://godbolt.org/z/W1zh9n
Status: UNCONFIRMED
  Keywords: accepts-invalid
  Severity: normal
  Priority: P3
 Component: d
  Assignee: ibuclaw at gdcproject dot org
  Reporter: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/W1zh9n.
```C++
template  concept Int = requires { T{0}; };
template  class T> struct X{ };
template/* ^~~ */struct Y : X { };
  struct Z{ };
void f() { Y x; }
```

[Bug c++/96242] New: ICE conditionally noexcept defaulted comparison

2020-07-19 Thread johelegp at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96242

Bug ID: 96242
   Summary: ICE conditionally noexcept defaulted comparison
   Product: gcc
   Version: 11.0
   URL: https://godbolt.org/z/z4q4Tv
Status: UNCONFIRMED
  Keywords: ice-on-valid-code
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/z4q4Tv.
```C++
template 
struct X
{
bool operator==(const X&) const noexcept(B) = default;
};
using Y = decltype(X{} == X{});
```
```C++
#include 
template 
struct X
{
auto operator<=>(const X&) const noexcept(B) = default;
};
using Y = decltype(X{} <= X{});
```

[Bug c++/96256] New: Invalid consteval call not rejected

2020-07-20 Thread johelegp at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96256

Bug ID: 96256
   Summary: Invalid consteval call not rejected
   Product: gcc
   Version: 11.0
   URL: https://godbolt.org/z/zeEY96
Status: UNCONFIRMED
  Keywords: accepts-invalid
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/zeEY96.
```C++
struct X
{
consteval X operator+() const { return {}; }
};
consteval void g(X) { }
void f()
{
X x;
+x;
g(x);
}
```
This might generalize https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95593.

[Bug c++/96193] No ADL in dependent call with explicit template arguments

2020-07-24 Thread johelegp at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96193

Johel Ernesto Guerrero Peña  changed:

   What|Removed |Added

URL||https://godbolt.org/z/E64Pb
   ||b
Summary|No ADL in call with |No ADL in dependent call
   |explicit template arguments |with explicit template
   |within templated hidden |arguments
   |friend  |

--- Comment #4 from Johel Ernesto Guerrero Peña  ---
It actually fails for dependent calls. See https://godbolt.org/z/E64Pbb.
```C++
namespace ns {
  template  struct X { };
  template  constexpr void adl(X) { }
}
template  void f() { adl(ns::X{}); }
void g() { f(); }
```

[Bug c++/95434] ICE for CTAD in generic lambda within variadic lambda

2020-08-11 Thread johelegp at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95434

--- Comment #3 from Johel Ernesto Guerrero Peña  ---
Another example: https://godbolt.org/z/Wq1vjP. Perhaps, this too requires
another bug report.
```C++
template  class T, class... Us>
concept ctadable = requires(Us... us) { T{us...}; };

template 
struct X { T x; };

static_assert(ctadable);
```

[Bug c++/96790] New: Indirectly inherited default constructor doesn't zero-initialize

2020-08-25 Thread johelegp at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96790

Bug ID: 96790
   Summary: Indirectly inherited default constructor doesn't
zero-initialize
   Product: gcc
   Version: 11.0
   URL: https://godbolt.org/z/3563e1
Status: UNCONFIRMED
  Keywords: rejects-valid
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
    CC: johelegp at gmail dot com
  Target Milestone: ---

See the URL.
```C++
struct base0 {
int x;
base0() = default;
constexpr base0(int x) : x{x} { }
};

struct base1 : base0 {
using base0::base0;
constexpr base1(void*) : base0{} { }
};

struct derived : base1 { using base1::base1; };

void f() { []() consteval { derived{}.x + 1; }(); }
```

[Bug c++/65816] Constructor delegation does not perform zero-initialization

2020-08-27 Thread johelegp at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65816

Johel Ernesto Guerrero Peña  changed:

   What|Removed |Added

 CC||johelegp at gmail dot com

--- Comment #6 from Johel Ernesto Guerrero Peña  ---
*** Bug 96790 has been marked as a duplicate of this bug. ***

[Bug c++/96790] Indirectly inherited default constructor doesn't zero-initialize

2020-08-27 Thread johelegp at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96790

Johel Ernesto Guerrero Peña  changed:

   What|Removed |Added

   Keywords|rejects-valid   |wrong-code
 Resolution|--- |DUPLICATE
 Status|UNCONFIRMED |RESOLVED

--- Comment #2 from Johel Ernesto Guerrero Peña  ---
I agree.

*** This bug has been marked as a duplicate of bug 65816 ***

[Bug c++/96840] New: Recursive substitution in constrained commutative operator

2020-08-28 Thread johelegp at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96840

Bug ID: 96840
   Summary: Recursive substitution in constrained commutative
operator
   Product: gcc
   Version: 11.0
   URL: https://godbolt.org/z/cedacs
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
  Target Milestone: ---

I may be wrong, but I think this should compile. Clang accepts it as does GCC
10.2 and did the GCC 11 build from a little while ago.
See the URL:
```C++
template  concept C = requires(T t, U u) { t * u; };
template  struct Int {
 template  requires C friend void operator*(T, Int) { }
 template  requires C friend void operator*(Int, T) { }
};
void f() { 0 * Int{}; }
```

[Bug c++/96510] Unexpected constexpr deallocation error after implicit conversion

2020-08-28 Thread johelegp at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96510

Johel Ernesto Guerrero Peña  changed:

   What|Removed |Added

 CC||johelegp at gmail dot com

--- Comment #1 from Johel Ernesto Guerrero Peña  ---
This may be related to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95977.

[Bug c++/96242] ICE conditionally noexcept defaulted comparison

2020-09-05 Thread johelegp at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96242

--- Comment #2 from Johel Ernesto Guerrero Peña  ---
Thank you, but am I not exempt?

> The only excuses to not send us the preprocessed sources are [...] if you've 
> reduced the testcase to a small file that doesn't include any other file [...]

[Bug c++/86044] New: noexcept(false) of constexpr member function ignored

2018-06-04 Thread johelegp at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86044

Bug ID: 86044
   Summary: noexcept(false) of constexpr member function ignored
   Product: gcc
   Version: 8.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
  Target Milestone: ---

In the following snippet, the assertion fails if `constexpr` isn't commented
out. See https://godbolt.org/g/FCEHCb.

```C++
struct A {
};

template 
struct H {
constexpr
int operator()(const K&) const noexcept(false)
{
return 0;
}
};

static_assert(!noexcept(H()(A())), "");
```

[Bug c++/86105] New: Conversion to ambiguous/inaccessible rvalue base is valid in unevaluated context

2018-06-10 Thread johelegp at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86105

Bug ID: 86105
   Summary: Conversion to ambiguous/inaccessible rvalue base is
valid in unevaluated context
   Product: gcc
   Version: 8.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
  Target Milestone: ---

In the following snippet, the assertions fail although the `static_cast` is
ill-formed in non-unevaluated context. See https://godbolt.org/g/45VJvp, and a
related Clang report https://bugs.llvm.org/show_bug.cgi?id=37691.

```C++
#include 

template 
constexpr bool is_static_castable(...)
{
return false;
};

template <
class To, class From,
class = decltype(static_cast(std::declval()))>
constexpr bool is_static_castable(int)
{
return true;
};

struct B {
};

struct D : B {
};

struct D2
  : D
  , B {
};

static_assert(!is_static_castable(0), "");

struct D3 : private B {
};

static_assert(!is_static_castable(0), "");

void f()
{
D2 d2;
(void)static_cast(d2);
D3 d3;
(void)static_cast(d3);
}
```

[Bug c++/99365] New: ICE on partial specialization with constrained placeholder NTTP

2021-03-03 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99365

Bug ID: 99365
   Summary: ICE on partial specialization with constrained
placeholder NTTP
   Product: gcc
   Version: 11.0
   URL: https://godbolt.org/z/nxTEaW
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/nxTEaW.
```C++
templateconcept C=true;
templatestruct A{};
templaterequires true struct A{};
```
I think CE recompiles GCC trunk daily, and this was working yesterday.

[Bug c++/99366] New: Partial specialization with constrained placeholder NTTP is not more specialized

2021-03-03 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99366

Bug ID: 99366
   Summary: Partial specialization with constrained placeholder
NTTP is not more specialized
   Product: gcc
   Version: 11.0
   URL: https://godbolt.org/z/ETjYfP
Status: UNCONFIRMED
  Keywords: rejects-valid
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/ETjYfP.
```C++
templateconcept C=true;
templatestruct A{};
templaterequires true struct A{};
```
I think CE recompiles GCC trunk daily, and this was working yesterday.
Must be related to Bug 99365.

[Bug c++/99365] [11 Regression] ICE on partial specialization with constrained placeholder NTTP

2021-03-07 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99365

--- Comment #6 from Johel Ernesto Guerrero Peña  ---
Thank you. Can confirm it's working for my use case.

[Bug c++/99493] New: Address of template parameter object is not a valid template argument

2021-03-09 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99493

Bug ID: 99493
   Summary: Address of template parameter object is not a valid
template argument
   Product: gcc
   Version: 11.0
   URL: https://godbolt.org/z/9zYo8f
Status: UNCONFIRMED
  Keywords: rejects-valid
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/9zYo8f.
```C++
struct owner{int m;};
struct view{const int*m;constexpr view(const owner&o):m{&o.m}{}};
templatestruct constant{};
templateconstexpr constantv{};
[[maybe_unused]] constexpr auto a=v;
```
https://timsong-cpp.github.io/cppwp/n4861/temp.param#8 defines template
parameter object.
https://timsong-cpp.github.io/cppwp/n4861/temp.arg.nontype#2 makes the template
parameter object a constant expression.
https://timsong-cpp.github.io/cppwp/n4861/temp.arg.nontype#3 lists
restrictions, which excludes taking the address of a template parameter object.

[Bug c++/99501] New: Can't forward declare partial specialization of template with NTTP previously partially specialized

2021-03-09 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99501

Bug ID: 99501
   Summary: Can't forward declare partial specialization of
template with NTTP previously partially specialized
   Product: gcc
   Version: 11.0
   URL: https://godbolt.org/z/Mhnxrf
Status: UNCONFIRMED
  Keywords: rejects-valid
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
    CC: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/Mhnxrf.
```C++
templatestruct X;
templaterequires requires{V.a;}struct X;
templaterequires requires{V.b;}struct X;
```
Completed:
```C++
templatestruct X{};
templaterequires requires{V.a;}struct X{static constexpr bool
v{false};};
templaterequires requires{V.b;}struct X;
struct A{int a;};
static_assert(!X::v);
struct B{int b;};
templaterequires requires{V.b;}struct X{static constexpr bool
v{true};};
static_assert(X::v);
```

[Bug c++/99507] New: Can't return static address from immediate function

2021-03-09 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99507

Bug ID: 99507
   Summary: Can't return static address from immediate function
   Product: gcc
   Version: 11.0
   URL: https://godbolt.org/z/vnPToT
Status: UNCONFIRMED
  Keywords: rejects-valid
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
    CC: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/vnPToT.
```C++
constexpr int i{0};
consteval const int& iref() { return i; }
[[maybe_unused]] constexpr const int* a{&iref()};
```

[Bug c++/99524] New: initializer_list storage considered a temporary when accessed through NTTP

2021-03-10 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99524

Bug ID: 99524
   Summary: initializer_list storage considered a temporary when
accessed through NTTP
   Product: gcc
   Version: 11.0
   URL: https://godbolt.org/z/aWGr3P
Status: UNCONFIRMED
  Keywords: rejects-valid
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/aWGr3P.
```C++
#include
constexpr std::initializer_listil{true};
templateconstexpr bool front=B[0];
static_assert(front);
```
https://timsong-cpp.github.io/cppwp/n4861/dcl.init.list#5 explains its storage.
https://timsong-cpp.github.io/cppwp/n4861/dcl.init.list#6 explains its
lifetime.

[Bug c++/95015] Partial specializations of class templates with class NTTP fails

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

Johel Ernesto Guerrero Peña  changed:

   What|Removed |Added

 CC||johelegp at gmail dot com

--- Comment #1 from Johel Ernesto Guerrero Peña  ---
Seems fixed in trunk, with and without the deduction guide.

[Bug c++/99565] New: Bogus identical branches warning when returning references to union members

2021-03-12 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99565

Bug ID: 99565
   Summary: Bogus identical branches warning when returning
references to union members
   Product: gcc
   Version: 11.0
   URL: https://godbolt.org/z/9qaz9W
Status: UNCONFIRMED
  Keywords: diagnostic
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/9qaz9W.
```C++
struct A {
  union {
int a;
int b;
  };
  int& x() { return 0 ? a : b; }
};
```

[Bug c++/99571] New: ICE for NTTP with pointer to array of union

2021-03-12 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99571

Bug ID: 99571
   Summary: ICE for NTTP with pointer to array of union
   Product: gcc
   Version: 11.0
   URL: https://godbolt.org/z/rsc6fs
Status: UNCONFIRMED
  Keywords: ice-on-valid-code
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/rsc6fs.
```C++
struct I{
  union { int a[1]{}; };
  int*i=a;
};
constexpr I i;
templatestruct C{};
[[maybe_unused]]Cc;
```

[Bug c++/83258] Rejecting function pointer non-type template parameter without linkage

2021-03-13 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83258

Johel Ernesto Guerrero Peña  changed:

   What|Removed |Added

 CC||johelegp at gmail dot com

--- Comment #9 from Johel Ernesto Guerrero Peña  ---
I think Bug 97700 is also a duplicate of this.

[Bug c++/97700] Bogus error when a class containing a function pointer is used as a non-type template parameter

2021-03-13 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97700

--- Comment #3 from Johel Ernesto Guerrero Peña  ---
This seems to be a duplicate of Bug 83258.

[Bug c++/83258] Rejecting function pointer non-type template parameter without linkage

2021-03-13 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83258

--- Comment #10 from Johel Ernesto Guerrero Peña  ---
Another workaround, extended from Bug 92320's example. See
https://godbolt.org/z/69onWf.
You can wrap the closure object in a template function which itself invokes the
closure object and converts to a function pointer that GCC accepts.
```C++
template
void templ() {}

void dummy(){}

template
void fn(){F();}

void foo() {
constexpr int a = 7 + 3;
templ();

templ();

typedef void(FPtr)();
constexpr FPtr * b = &dummy;
templ();

constexpr auto l = []{};
constexpr void (*d)()=fn;
templ();

constexpr FPtr * c = [](){};
templ();
}

```

[Bug c++/97476] Use of NTTP placeholder checked for CTAD before instantiation

2021-03-14 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97476

Johel Ernesto Guerrero Peña  changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |FIXED

--- Comment #1 from Johel Ernesto Guerrero Peña  ---
Fixed in trunk.

[Bug c++/99586] New: Use of class template identifier checked for CTAD before instantiation

2021-03-14 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99586

Bug ID: 99586
   Summary: Use of class template identifier checked for CTAD
before instantiation
   Product: gcc
   Version: 11.0
   URL: https://godbolt.org/z/4KWWjT
Status: UNCONFIRMED
  Keywords: rejects-valid
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/4KWWjT.
```C++
#include
templatestruct A{};
templateA a=A{};
```

[Bug c++/99493] Address of template parameter object is not a valid template argument

2021-03-14 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99493

--- Comment #1 from Johel Ernesto Guerrero Peña  ---
Slightly simplified: https://godbolt.org/z/rv97Gh.
```C++
struct A{};
templateconstexpr const A*tpo{&a};
templatestruct B{};
B>b;
```
```
:4:10: error: the address of 'A{}' is not a valid template argument
4 | B>b;
  |  ^~
Compiler returned: 1
```

[Bug c++/99565] Bogus identical branches warning when returning references to union members

2021-03-15 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99565

--- Comment #2 from Johel Ernesto Guerrero Peña  ---
```
: In member function 'int& A::x()':
:6:23: warning: this condition has identical branches
[-Wduplicated-branches]
6 |   int& x() { return 0 ? a : b; }
  | ~~^~~
```

My actual use case looks more like this: https://godbolt.org/z/W5ajeM.
```C++
struct A {
  char x;
  long long y;
};
struct B {
  double x;
  long long y;
};
struct C {
  int i;
  union {
A a;
B b;
  };
  long long& y() { return i ? a.y : b.y; }
};
```
```
: In member function 'long long int& C::y()':
:15:29: warning: this condition has identical branches
[-Wduplicated-branches]
   15 |   long long& y() { return i ? a.y : b.y; }
  |   ~~^~~
```

[Bug c++/99493] Address of template parameter object is not a valid template argument

2021-03-15 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99493

--- Comment #2 from Johel Ernesto Guerrero Peña  ---
Looks like you can get away by instead passing around a pointer to the address
of the template parameter object: https://godbolt.org/z/o3Paz1.
```C++
struct A{};
templateconstexpr const A*tpo{&a};
constexpr A ga{};
templaterequires(a==&tpo)struct B{};
[[maybe_unused]]B<&tpo>b;
```

[Bug c++/99622] New: Materialized temporary is not usable in a constant expression

2021-03-16 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99622

Bug ID: 99622
   Summary: Materialized temporary is not usable in a constant
expression
   Product: gcc
   Version: 11.0
   URL: https://godbolt.org/z/M4Ya9h
Status: UNCONFIRMED
  Keywords: rejects-valid
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/M4Ya9h.

```C++
const bool& b = bool{true};
static_assert(b);
```
```
:2:15: error: non-constant condition for static assertion
2 | static_assert(b);
  |   ^
:2:15: error: the value of '' is not usable in a constant
expression
:1:26: note: 'bool ' is not const
1 | const bool& b = bool{true};
  |  ^
Compiler returned: 1
```

```C++
struct A { bool b{true}; };
const A& a = A{};
static_assert(a.b);
```
```
:3:17: error: non-constant condition for static assertion
3 | static_assert(a.b);
  |   ~~^
:3:17: error: the value of '' is not usable in a constant
expression
:2:16: note: '' was not declared 'constexpr'
2 | const A& a = A{};
  |^
Compiler returned: 1
```

[Bug c++/99631] New: decltype of non-type template-parameter shouldn't be const

2021-03-17 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99631

Bug ID: 99631
   Summary: decltype of non-type template-parameter shouldn't be
const
   Product: gcc
   Version: 11.0
   URL: https://godbolt.org/z/4YY5r3
Status: UNCONFIRMED
  Keywords: rejects-valid
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
    CC: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/4YY5r3.
```C++
#include
templateconstexpr bool is_const=std::is_const_v;
struct A{};
static_assert(!is_const);
```
```
:4:15: error: static assertion failed
4 | static_assert(!is_const);
  |   ^~
Compiler returned: 1
```
See https://bugs.llvm.org/show_bug.cgi?id=49609#c1 for an explanation.

[Bug c++/99631] decltype of non-type template-parameter shouldn't be const

2021-03-18 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99631

--- Comment #3 from Johel Ernesto Guerrero Peña  ---
Good point. How about 'conformance' for a keyword?

[Bug c++/96873] Internal compiler error in alias_ctad_tweaks

2021-04-06 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96873

Johel Ernesto Guerrero Peña  changed:

   What|Removed |Added

 CC||johelegp at gmail dot com

--- Comment #6 from Johel Ernesto Guerrero Peña  ---
Could this be a duplicate of Bug 95486?

[Bug c++/99586] Use of class template identifier checked for CTAD before instantiation

2021-04-21 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99586

--- Comment #4 from Johel Ernesto Guerrero Peña  ---
Thank you.

[Bug c++/95486] ICE for alias CTAD with non-dependent argument and constrained constructor

2021-04-24 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95486

--- Comment #11 from Johel Ernesto Guerrero Peña  ---
Thank you. But the first CE link: https://godbolt.org/z/cPWdGW, and with the
addition in Comment 2: https://godbolt.org/z/Gezh5h5W4, they still ICE.

[Bug c++/93085] ICE in get_class_binding_direct and alias_ctad_tweaks, with C++20 NTTP + CTAD + alias template

2020-10-17 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93085

Johel Ernesto Guerrero Peña  changed:

   What|Removed |Added

 CC||johelegp at gmail dot com

--- Comment #2 from Johel Ernesto Guerrero Peña  ---
Invalid because it passes (a) type template argument(s) to a template template
parameter.

[Bug c++/97476] New: Use of NTTP placeholder checked for CTAD before instantiation

2020-10-17 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97476

Bug ID: 97476
   Summary: Use of NTTP placeholder checked for CTAD before
instantiation
   Product: gcc
   Version: 11.0
   URL: https://godbolt.org/z/ocWhn8
Status: UNCONFIRMED
  Keywords: rejects-valid
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
  Target Milestone: ---

See the URL.
```C++
template  struct S { };
template  class C { };
template  using A = C;
```
[93083](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93083) may be a duplicate
of this.

[Bug c++/93085] ICE in get_class_binding_direct and alias_ctad_tweaks, with C++20 NTTP + CTAD + alias template

2020-10-17 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93085

--- Comment #4 from Johel Ernesto Guerrero Peña  ---
> GCC shouldn't even be trying to resolve `foo<42>()` until `G` has been 
> instantiated.

That's right. I came across this bug report when reporting such an issue:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97476.

[Bug libstdc++/95788] std::ranges::construct_at's placement new not intercepted

2020-10-08 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95788

--- Comment #3 from Johel Ernesto Guerrero Peña  ---
Thank you. Sorry for my laziness, but did you confirm this from the OP?
> Other stuff in `bits/ranges_uninitialized.h` may be similarly affected.

[Bug c++/98486] New: Variable template specialization doesn't account for primary's constraints

2020-12-30 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98486

Bug ID: 98486
   Summary: Variable template specialization doesn't account for
primary's constraints
   Product: gcc
   Version: 11.0
   URL: https://godbolt.org/z/jon9ea
Status: UNCONFIRMED
  Keywords: accepts-invalid
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/jon9ea.
```C++
templateconcept C=false;
templateint v;
struct X{};
template<>X v;
```

[Bug c++/98832] New: CTAD fails for alias template of aggregate with specified undeducible template parameter

2021-01-25 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98832

Bug ID: 98832
   Summary: CTAD fails for alias template of aggregate with
specified undeducible template parameter
   Product: gcc
   Version: 11.0
   URL: https://godbolt.org/z/M1eqvq
Status: UNCONFIRMED
  Keywords: rejects-valid
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/M1eqvq.
```C++
templatestruct X{U u;};
templateusing Y=X;
Y y{0};
```

[Bug c++/98844] New: Deduction guides don't inhibit the aggregate deduction candidate

2021-01-26 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98844

Bug ID: 98844
   Summary: Deduction guides don't inhibit the aggregate deduction
candidate
   Product: gcc
   Version: 11.0
   URL: https://godbolt.org/z/EWs4rd
Status: UNCONFIRMED
  Keywords: accepts-invalid
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
    CC: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/EWs4rd.
```C++
#include
templatestruct A{T t;};
A(double)->A;
A a{1};
static_assert(std::is_same_v>);
```

[Bug c++/98924] New: Ambiguous name in concept-id diagnosed as parser error

2021-02-01 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98924

Bug ID: 98924
   Summary: Ambiguous name in concept-id diagnosed as parser error
   Product: gcc
   Version: 11.0
   URL: https://godbolt.org/z/Txrvos
Status: UNCONFIRMED
  Keywords: diagnostic
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/Txrvos.
```C++
namespace A{bool X;}
namespace B{bool X;}
using namespace A;
using namespace B;
templateconcept C=true;
bool b=C;
```
```
:6:8: error: parse error in template argument list
6 | bool b=C;
  |^~~~
:6:8: error: template argument 1 is invalid
Compiler returned: 1
```

[Bug c++/95486] ICE for alias CTAD with non-dependent argument and constrained constructor

2021-02-02 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95486

--- Comment #5 from Johel Ernesto Guerrero Peña  ---
Thank you. I was under the mistaken impression that the above was only a
partial solution. Adding the following deduction guide restores the ICE. See
https://godbolt.org/z/fej7WT.
```C++
template
X(U) -> X;
```

[Bug c++/95434] ICE for CTAD in generic lambda within variadic lambda

2021-02-02 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95434

Johel Ernesto Guerrero Peña  changed:

   What|Removed |Added

  Known to work||11.0
 Status|ASSIGNED|RESOLVED
URL||https://godbolt.org/z/-fZVX
   ||4
  Known to fail||10.1.0
 Resolution|--- |FIXED

--- Comment #6 from Johel Ernesto Guerrero Peña  ---
Thank you.

[Bug c++/99141] New: Name of deduced type unchecked in deduction guide

2021-02-17 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99141

Bug ID: 99141
   Summary: Name of deduced type unchecked in deduction guide
   Product: gcc
   Version: 11.0
   URL: https://godbolt.org/z/bEhjsc
Status: UNCONFIRMED
  Keywords: accepts-invalid
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
  Target Milestone: ---

Context
(https://timsong-cpp.github.io/cppwp/n4861/temp.deduct.guide#nt:deduction-guide):
> deduction-guide:
>   explicit-specifieropt template-name ( parameter-declaration-clause ) -> 
> simple-template-id ;
The requirement
(https://timsong-cpp.github.io/cppwp/n4861/temp.deduct.guide#3.sentence-3):
> The template-name shall be the same identifier as the template-name of the 
> simple-template-id.
See https://godbolt.org/z/bEhjsc.
```C++
templatestruct A;
templateusing B=A;
A(int)->B;
```

[Bug c++/95486] ICE for alias CTAD with non-dependent argument and constrained constructor

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

--- Comment #13 from Johel Ernesto Guerrero Peña  ---
You're right. I thought they were compiling against GCC trunk.

[Bug c++/103524] [meta-bug] modules issue

2023-03-04 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103524
Bug 103524 depends on bug 102524, which changed state.

Bug 102524 Summary: [modules] Missing diagnostic when an exported namespace is 
empty
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102524

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |FIXED

[Bug c++/102524] [modules] Missing diagnostic when an exported namespace is empty

2023-03-04 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102524

Johel Ernesto Guerrero Peña  changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|UNCONFIRMED |RESOLVED

--- Comment #1 from Johel Ernesto Guerrero Peña  ---
Clang no longer warns. This was resolved with
https://github.com/cplusplus/draft/commit/f3ffeb4f05fe4302d8ecee129e72f4e99e10dc02,
which striked the quoted sentence.

[Bug c++/104993] New: [modules] Missing diagnostic when exporting using-directive

2022-03-20 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104993

Bug ID: 104993
   Summary: [modules] Missing diagnostic when exporting
using-directive
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Keywords: diagnostic
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
  Target Milestone: ---

[module.interface]p3s1 says
> An exported declaration that is not a module-import-declaration shall declare 
> at least one name.
And its following example includes the line
> `export using namespace N;   // error: does not declare a name`
https://godbolt.org/z/aGY9b6x66 shows Clang give a warning.
> mod.cpp:3:38: warning: ISO C++20 does not permit using directive to be 
> exported [-Wexport-using-directive]
> export namespace y { using namespace x; }
> ^
> 1 warning generated.
GCC is silent: https://godbolt.org/z/zP6648s46.

Source:
```C++
export module mod;
export namespace x { int y; }
export namespace y { using namespace x; }
```

[Bug c++/100687] [modules, concepts] imported concept gives different result

2022-03-23 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100687

--- Comment #2 from Johel Ernesto Guerrero Peña  ---
Another use case (Clang: https://godbolt.org/z/hTPsPbEhe) (GCC:
https://godbolt.org/z/96MqTvrKv):

`mod.cpp`:
```C++
export module mod;
export template
inline constexpr bool is_same_v = false;
export template
inline constexpr bool is_same_v = true;
```

`test.cpp`:
```C++
import mod;
static_assert(is_same_v);
int main() {
}
```

Output:
```
test.cpp:2:15: error: static assertion failed
2 | static_assert(is_same_v);
  |   ^~~
```

[Bug c++/102598] [modules] ICE in pp_string, at pretty-print.c

2022-03-23 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102598

--- Comment #2 from Johel Ernesto Guerrero Peña  ---
Another test case: https://godbolt.org/z/Gsfx56GM9.

[Bug c++/105044] New: [modules] ICE in comptypes, at cp/typeck.c:1529

2022-03-24 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105044

Bug ID: 105044
   Summary: [modules] ICE in comptypes, at cp/typeck.c:1529
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Keywords: ice-on-valid-code
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/YGo78aPE8.

`mod.cpp`:
```C++
export module mod;

export template
struct downcast_base {
  using downcast_base_type = BaseType;
  friend auto downcast_guide(downcast_base);
};

export template concept Downcastable = true;

export template
struct downcast_child : T {
  friend auto downcast_guide(typename T::downcast_base) { return T(); }
};

export struct ratio { int num; };

export template
struct scaled_unit : downcast_base> {};

export template
struct unit : downcast_child> {};

export struct unknown_coherent_unit : unit {};
```

`test.cpp`:
```C++
import mod;
struct u : downcast_base { };
int main() { }
```

Output:
```
In module mod, imported at /app/test.cpp:1:
mod.cpp: In instantiation of 'struct downcast_base@mod':
test.cpp:2:12:   required from here
mod.cpp:4:8: internal compiler error: in comptypes, at cp/typeck.cc:1529
4 | struct downcast_base {
  |^
0x218c519 internal_error(char const*, ...)
???:0
0x741b3f fancy_abort(char const*, int, char const*)
???:0
0xa7e346 comptypes(tree_node*, tree_node*, int)
???:0
0x828f6d complete_vars(tree_node*)
???:0
0x7a1a5c finish_struct_1(tree_node*)
???:0
0xa01359 instantiate_class_template(tree_node*)
???:0
0xa7739b complete_type_or_maybe_complain(tree_node*, tree_node*, int)
???:0
0x841a1c xref_basetypes(tree_node*, tree_node*)
???:0
0x986b0d c_parse_file()
???:0
0xb18ae2 c_common_parse_file()
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
```

[Bug c++/105045] New: [modules] Can't deduce defaulted template parameter

2022-03-24 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105045

Bug ID: 105045
   Summary: [modules] Can't deduce defaulted template parameter
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Keywords: rejects-valid
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/3WMd4T48h.

`mod.cpp`:
```C++
export module mod;
export template void f(U) { }
```

`test.cpp`:
```C++
import mod;
int main() { f(0); }
```

Output:
```
test.cpp: In function 'int main()':
test.cpp:2:15: error: no matching function for call to 'f(int)'
2 | int main() { f(0); }
  |  ~^~~
In module mod, imported at /app/test.cpp:1:
mod.cpp:2:40: note: candidate: 'template void f@mod(U)'
2 | export template void f(U) { }
  |^
mod.cpp:2:40: note:   template argument deduction/substitution failed:
test.cpp:2:15: note:   couldn't deduce template parameter 'T'
2 | int main() { f(0); }
  |  ~^~~
```

[Bug c++/105106] New: Dependent invocation with defaulted NTTP lambda fails

2022-03-30 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105106

Bug ID: 105106
   Summary: Dependent invocation with defaulted NTTP lambda fails
   Product: gcc
   Version: 9.4.1
Status: UNCONFIRMED
  Keywords: rejects-valid
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/obfY3Mdba:
```C++
template 
auto foo() {
return l;
}

template 
auto bar() {
return foo();
}
```

The error message looks cut short:
```
: In function 'auto bar()':
:8:16: error: no matching function for call to 'foo()'
8 | return foo();
  |^
:2:6: note: candidate: 'template auto foo()'
2 | auto foo() {
  |  ^~~
:2:6: note:   template argument deduction/substitution failed:
```

[Bug c++/105106] Dependent invocation with defaulted NTTP lambda fails

2022-03-30 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105106

--- Comment #1 from Johel Ernesto Guerrero Peña  ---
There is implementation divergence in the resulting closure type(s):
https://godbolt.org/z/W98r49o8s.

[Bug c++/106430] New: [modules] ICE on function result of imported type with user-declared constexpr destructor

2022-07-24 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106430

Bug ID: 106430
   Summary: [modules] ICE on function result of imported type with
user-declared constexpr destructor
   Product: gcc
   Version: 13.0
Status: UNCONFIRMED
  Keywords: ice-on-valid-code
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/Tr575rbj9.

mod.cpp:
```C++
export module mod;

struct X {
  bool b = true;
  constexpr ~X() { }
};

export constexpr X f() { return {}; }
```

test.cpp:
```C++
import mod;
static_assert(f().b);
int main() { }
```

Output:
```
test.cpp:2:21:   in 'constexpr' expansion of 'f@mod()()'
test.cpp:2:21: internal compiler error: in cxx_eval_call_expression, at
cp/constexpr.cc:2850
2 | static_assert(f().b);
  | ^
0x23010ce internal_error(char const*, ...)
???:0
0xa8f3bc fancy_abort(char const*, int, char const*)
???:0
0xaf4d0c maybe_constant_value(tree_node*, tree_node*, bool)
???:0
0xce57cf finish_static_assert(tree_node*, tree_node*, unsigned int, bool, bool)
???:0
0xc656d7 c_parse_file()
???:0
0xd9ec99 c_common_parse_file()
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
```

[Bug c++/106304] [modules] ICE compiling dynamic_cast in constexpr function (in tree_node, at cp/module.cc:9183)

2022-07-26 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106304

--- Comment #2 from Johel Ernesto Guerrero Peña  ---
This is the best I can do without having to manually de-noise CMake's compile
commands: https://godbolt.org/z/6s1GGYhM4.

[Bug c++/106430] [modules] ICE on function result of imported type with user-declared constexpr SMF

2022-07-27 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106430

Johel Ernesto Guerrero Peña  changed:

   What|Removed |Added

Summary|[modules] ICE on function   |[modules] ICE on function
   |result of imported type |result of imported type
   |with user-declared  |with user-declared
   |constexpr destructor|constexpr SMF

--- Comment #1 from Johel Ernesto Guerrero Peña  ---
See https://godbolt.org/z/T8591z1nT with copy constructor:

`mod.cpp`:
```C++
export module mod;

export struct X {
  bool b = true;
  X() = default;
  constexpr X(const X&) { }
};

export constexpr X id(X x) { return x; }
```

`test.cpp`:
```C++
import mod;
static_assert(id(X{}).b);
int main() { }
```

Output:
```
test.cpp:2:25:   in 'constexpr' expansion of 'id@mod(X@mod)()'
test.cpp:2:25: internal compiler error: in cxx_eval_call_expression, at
cp/constexpr.cc:2850
2 | static_assert(id(X{}).b);
  | ^
0x230869e internal_error(char const*, ...)
???:0
0xa90716 fancy_abort(char const*, int, char const*)
???:0
0xaf60ac maybe_constant_value(tree_node*, tree_node*, bool)
???:0
0xce6baf finish_static_assert(tree_node*, tree_node*, unsigned int, bool, bool)
???:0
0xc66a77 c_parse_file()
???:0
0xda0269 c_common_parse_file()
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See  for instructions.
```

[Bug c++/106485] New: Can't use heap pointer in `static_assert`

2022-07-30 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106485

Bug ID: 106485
   Summary: Can't use heap pointer in `static_assert`
   Product: gcc
   Version: 13.0
Status: UNCONFIRMED
  Keywords: rejects-valid
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
    CC: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/W4r6oMa3M.

```C++
struct I {
  int* i = new int{1};
  constexpr ~I() { delete i; }
};
static_assert([] { return I{}.i; }());
static_assert(I{}.i);
```

```
:5:19: error: non-constant condition for static assertion
5 | static_assert(I{}.i);
  |   ^
:5:19: error: the value of '' is not usable in a constant
expression
:5:17: note: '' was not declared 'constexpr'
5 | static_assert(I{}.i);
  | ^
Compiler returned: 1
```

It works wrapped in an IILE, or if the `int` is uninitialized.

[Bug c++/106826] New: [modules] Variable template of type trait via importable header gives wrong result

2022-09-04 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106826

Bug ID: 106826
   Summary: [modules] Variable template of type trait via
importable header gives wrong result
   Product: gcc
   Version: 13.0
Status: UNCONFIRMED
  Keywords: rejects-valid
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/Yjrcv6sG1.

```sh
CXX=/home/johel/root/gcc/bin/g++
echo "./my.std.headers.hpp my.std.headers.gcm
my.std my.std.gcm
my.module my.module.gcm" > mm.txt
echo "#include " > my.std.headers.hpp
echo "export module my.std;
export import \"my.std.headers.hpp\";" > my.std.cpp
echo "export module my.module;
import my.std;
static_assert(std::is_lvalue_reference_v);
export int _;" > my.module.cpp
$CXX -std=c++23 -fmodules-ts -fmodule-mapper=mm.txt -x c++-header -c
my.std.headers.hpp
$CXX -std=c++23 -fmodules-ts -fmodule-mapper=mm.txt -c my.std.cpp
$CXX -std=c++23 -fmodules-ts -fmodule-mapper=mm.txt -c my.module.cpp
```

Output:
```
my.module.cpp:3:20: error: static assertion failed
3 | static_assert(std::is_lvalue_reference_v);
  |   ~^~~
my.module.cpp:1:8: warning: not writing module ‘my.module’ due to errors
1 | export module my.module;
  |^~
```

GCC12 passes the assertion.

[Bug c++/106826] [13 Regression] [modules] Variable template of type trait via importable header gives wrong result

2022-09-05 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106826

Johel Ernesto Guerrero Peña  changed:

   What|Removed |Added

  Known to work||12.2.0
  Known to fail||13.0
Summary|[modules] Variable template |[13 Regression] [modules]
   |of type trait via   |Variable template of type
   |importable header gives |trait via importable header
   |wrong result|gives wrong result

--- Comment #1 from Johel Ernesto Guerrero Peña  ---
As mentioned, this works with GCC 12: https://godbolt.org/z/bnfzPc5M8.

[Bug c++/106851] [modules] Name conflict for exported using-declaration

2022-09-06 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106851

Johel Ernesto Guerrero Peña  changed:

   What|Removed |Added

 CC||johelegp at gmail dot com

--- Comment #1 from Johel Ernesto Guerrero Peña  ---
Could https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106363 be related?

[Bug c++/106485] Can't use heap pointer in `static_assert`

2022-09-08 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106485

--- Comment #2 from Johel Ernesto Guerrero Peña  ---
I think that's different. Actually, I think it's Clang that's wrong. As
mentioned at
https://cpplang.slack.com/archives/C21PKDHSL/p1656857369259539?thread_ts=1656856509.892079&cid=C21PKDHSL:
> The expression of the `static_assert` is not an
> [immediate function 
> context](https://eel.is/c++draft/expr.const#def:immediate_function_context).
> Wrapping it in `[]() consteval { return s().empty(); }()` 
> [works](https://godbolt.org/z/PKTE7zofW),
> whereas removing that `consteval` causes Clang to also complain.

See https://godbolt.org/z/4GMxo13vv.
```C++
#include 
consteval auto s() { return std::string(); }
static_assert(s().empty()); // Only Clang accepts.
// static_assert([]() consteval { return s().empty(); }()); // All accept.
// static_assert([]() { return s().empty(); }()); // All reject.
```

Opened https://github.com/llvm/llvm-project/issues/57627 for that.

[Bug c++/106826] [13 Regression] [modules] Variable template of type trait via importable header gives wrong result

2022-09-21 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106826

--- Comment #3 from Johel Ernesto Guerrero Peña  ---
So this is a duplicate of Bug 100687.

[Bug c++/106826] [13 Regression] [modules] Variable template of type trait via importable header gives wrong result

2022-09-22 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106826

--- Comment #7 from Johel Ernesto Guerrero Peña  ---
Thank you very much! This was a real blocker.

[Bug c++/102284] Can access object outside of its lifetime during constant evaluation

2022-09-24 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102284

--- Comment #6 from Johel Ernesto Guerrero Peña  ---
Another example.

Simplified: https://godbolt.org/z/z781c56PM.

```C++
struct ratio {
  int numerator;
};

template struct constant;

template concept constant_invocable = requires { typename
constant<(F(), 0)>; };

static_assert(not constant_invocable<[] {
  ratio r;
  (void)int{r.*&ratio::numerator};
}>);
```

```
:9:15: error: static assertion failed
9 | static_assert(not constant_invocable<[] {
  |   ^~~
   10 |   ratio r;
  |    
   11 |   (void)int{r.*&ratio::numerator};
  |   
   12 | }>);
  | ~~ 
Compiler returned: 1
```

Found while opening https://github.com/llvm/llvm-project/issues/57958:
https://godbolt.org/z/KWfvEnaae.

```C++
#include 
#include 
#include 
#include 

struct ratio {
  std::intmax_t numerator;
  std::intmax_t denominator{1};
};

template concept constant_invocable = requires { typename
std::integral_constant; };

template requires std::is_member_object_pointer_v
inline constexpr bool default_initialization_leaves_uninitialized =
  [](M T::*) {
return not constant_invocable<[]() {
  T v;
  (void)M{v.*P};
}>;
  }(P);

static_assert(default_initialization_leaves_uninitialized<&ratio::numerator>);
static_assert(not
default_initialization_leaves_uninitialized<&ratio::denominator>);
```

```
:22:15: error: static assertion failed
   22 |
static_assert(default_initialization_leaves_uninitialized<&ratio::numerator>);
  |  
^~
Compiler returned: 1
```

[Bug c++/107033] New: [13 Regression] [modules] ICE converting to span

2022-09-25 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107033

Bug ID: 107033
   Summary: [13 Regression] [modules] ICE converting to span
   Product: gcc
   Version: 13.0
Status: UNCONFIRMED
  Keywords: rejects-valid
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
  Target Milestone: ---

See GCC trunk: https://godbolt.org/z/KoP5qo1Ks.
See GCC 12: https://godbolt.org/z/EfGjdcYaW.


```sh
CXX=/home/johel/root/gcc/bin/g++
echo "./std.hpp std.gcm
mod mod.gcm" > mm.txt
echo "#include 
#include " > std.hpp
echo "export module mod;
import \"std.hpp\";
constexpr std::array a = {};
export constexpr std::span s   = a;" > mod.cpp
$CXX -std=c++23 -fmodules-ts -fmodule-mapper=mm.txt -x c++-header -c std.hpp
$CXX -std=c++23 -fmodules-ts -fmodule-mapper=mm.txt -c mod.cpp
```

Output:
```
mod.cpp:1:8: internal compiler error: Segmentation fault
1 | export module mod;
  |^~
0x22c23ec internal_error(char const*, ...)
???:0
0xba7787 walk_specializations(bool, void (*)(bool, spec_entry*, void*), void*)
???:0
0xafa362 depset::hash::add_specializations(bool)
???:0
0xb0ab3c module_state::write_begin(elf_out*, cpp_reader*, module_state_config&,
unsigned int&)
???:0
0xb0c044 finish_module_processing(cpp_reader*)
???:0
0xa95334 c_parse_final_cleanups()
???:0
0xccde92 c_common_parse_file()
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://bugs.archlinux.org/> for instructions.
```

[Bug c++/107033] [13 Regression] [modules] ICE converting to span

2022-09-25 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107033

Johel Ernesto Guerrero Peña  changed:

   What|Removed |Added

   Keywords||ice-on-valid-code
  Known to fail||11.3.0, 12.2.0

--- Comment #1 from Johel Ernesto Guerrero Peña  ---
Simplified. GCC12 only accepts when the span is an lvalue, and otherwise is
rejects-valid. GCC11 and GCC13 are ice-on-valid-code with different backtraces.

GCC11: https://godbolt.org/z/ev5Wb4d3v
GCC12: https://godbolt.org/z/bo6f5nT7Y
GCC13: https://godbolt.org/z/qGdWq4383
GCC12 lvalue: https://godbolt.org/z/zoz69ener

GCC11:
```
In file included from /app/std.hpp:2,
of module /app/std.hpp, imported at /app/mod.cpp:2:
/opt/compiler-explorer/gcc-11.3.0/include/c++/11.3.0/span: In instantiation of
'class std::span':
mod.cpp:3:51:   required from here
/opt/compiler-explorer/gcc-11.3.0/include/c++/11.3.0/span:155:9: internal
compiler error: Segmentation fault
  155 | span(_It __first, size_type __count)
  | ^~~~
0x17888c9 internal_error(char const*, ...)
???:0
0x7da897 tsubst(tree_node*, tree_node*, int, tree_node*)
???:0
0x7f6feb instantiate_class_template(tree_node*)
???:0
0x82a7f3 complete_type(tree_node*)
???:0
0x806c31 finish_compound_literal(tree_node*, tree_node*, int, fcl_t)
???:0
0x7c123b c_parse_file()
???:0
0x894042 c_common_parse_file()
???:0
```

GCC12:
```
mod.cpp:3:35: error: no match for call to '(const
std::ranges::__cust_access::_Begin) (std::span)'
3 | export auto _ = std::ranges::begin(std::span{});
  | ~~^~
In file included from
/opt/compiler-explorer/gcc-12.2.0/include/c++/12.2.0/string_view:50,
 from
/opt/compiler-explorer/gcc-12.2.0/include/c++/12.2.0/bits/basic_string.h:47,
 from
/opt/compiler-explorer/gcc-12.2.0/include/c++/12.2.0/string:53,
 from
/opt/compiler-explorer/gcc-12.2.0/include/c++/12.2.0/bits/locale_classes.h:40,
 from
/opt/compiler-explorer/gcc-12.2.0/include/c++/12.2.0/bits/ios_base.h:41,
 from
/opt/compiler-explorer/gcc-12.2.0/include/c++/12.2.0/streambuf:41,
 from
/opt/compiler-explorer/gcc-12.2.0/include/c++/12.2.0/bits/streambuf_iterator.h:35,
 from
/opt/compiler-explorer/gcc-12.2.0/include/c++/12.2.0/iterator:66,
 from
/opt/compiler-explorer/gcc-12.2.0/include/c++/12.2.0/ranges:43,
 from /app/std.hpp:1,
of module /app/std.hpp, imported at /app/mod.cpp:2:
/opt/compiler-explorer/gcc-12.2.0/include/c++/12.2.0/bits/ranges_base.h:114:9:
note: candidate: 'template  requires (__maybe_borrowed_range<_Tp>)
&& ((is_array_v::type>) ||
(__member_begin<_Tp>) || (__adl_begin<_Tp>)) constexpr auto
std::ranges::__cust_access::_Begin::operator()(_Tp&&) const'
  114 | operator()[[nodiscard]](_Tp&& __t) const
noexcept(_S_noexcept<_Tp&>())
  | ^~~~
/opt/compiler-explorer/gcc-12.2.0/include/c++/12.2.0/bits/ranges_base.h:114:9:
note:   template argument deduction/substitution failed:
/opt/compiler-explorer/gcc-12.2.0/include/c++/12.2.0/bits/ranges_base.h:114:9:
note: constraints not satisfied
mod.cpp: In substitution of 'template  requires
(__maybe_borrowed_range<_Tp>) && ((is_array_v::type>) || (__member_begin<_Tp>) ||
(__adl_begin<_Tp>)) constexpr auto
std::ranges::__cust_access::_Begin::operator()(_Tp&&) const [with _Tp =
std::span]':
mod.cpp:3:35:   required from here
/opt/compiler-explorer/gcc-12.2.0/include/c++/12.2.0/bits/ranges_base.h:83:15: 
 required for the satisfaction of '__maybe_borrowed_range<_Tp>' [with _Tp =
std::span]
/opt/compiler-explorer/gcc-12.2.0/include/c++/12.2.0/bits/ranges_base.h:85:11:
note: no operand of the disjunction is satisfied
   84 | = is_lvalue_reference_v<_Tp>
  |   ~~
   85 |   || enable_borrowed_range>;
  |   ^
cc1plus: note: set '-fconcepts-diagnostics-depth=' to at least 2 for more
detail
mod.cpp:1:8: warning: not writing module 'mod' due to errors
1 | export module mod;
  |^~
```

GCC13:
```
mod.cpp:1:8: internal compiler error: Segmentation fault
1 | export module mod;
  |^~
0x234bd6e internal_error(char const*, ...)
???:0
0xc84cfe walk_specializations(bool, void (*)(bool, spec_entry*, void*), void*)
???:0
0xbead4c depset::hash::add_specializations(bool)
???:0
0xbfb5a8 module_state::write_begin(elf_out*, cpp_reader*, module_state_config&,
unsigned int&)
???:0
0xbfcd45 finish_module_processing(cpp_reader*)
???:0
0xb89d2e c_parse_final_cleanups()
???:0
0xdb0cc8 c_common_parse_file()
???:0
```

[Bug c++/107033] [13 Regression] [modules] ICE converting to span

2022-09-25 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107033

--- Comment #2 from Johel Ernesto Guerrero Peña  ---
Does it count as a regression if rejects-valid becomes ice-on-valid-code? IIRC,
~3 weeks ago the lvalue case was rejects-valid, like GCC12.

[Bug c++/107033] [13 Regression] [modules] ICE using span as a range

2022-09-25 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107033

--- Comment #3 from Johel Ernesto Guerrero Peña  ---
Simplified: https://godbolt.org/z/3Ys316aeE.

```C++
export module mod;
import "std.hpp";
int x[2];
export auto _ = std::ranges::begin(x);
```

[Bug c++/107033] [13 Regression] [modules] ICE using span as a range

2022-09-25 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107033

--- Comment #4 from Johel Ernesto Guerrero Peña  ---
This is actually Bug 106826.

Simplest: https://godbolt.org/z/oKT4x9r4G.

```C++
template constexpr bool is = false;
template constexpr bool is = true;
```

```C++
export module mod;
import "std.hpp";
static_assert(is);
```

```
mod.cpp:1:8: internal compiler error: Segmentation fault
1 | export module mod;
  |^~
0x234bd6e internal_error(char const*, ...)
???:0
0xc84cfe walk_specializations(bool, void (*)(bool, spec_entry*, void*), void*)
???:0
0xbead4c depset::hash::add_specializations(bool)
???:0
0xbfb5a8 module_state::write_begin(elf_out*, cpp_reader*, module_state_config&,
unsigned int&)
???:0
0xbfcd45 finish_module_processing(cpp_reader*)
???:0
0xb89d2e c_parse_final_cleanups()
???:0
0xdb0cc8 c_common_parse_file()
???:0
```

[Bug c++/106826] [13 Regression] [modules] Variable template of type trait via importable header gives wrong result

2022-09-25 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106826

--- Comment #8 from Johel Ernesto Guerrero Peña  ---
The original reproducer now ICEs. I opened Bug 107033 for this. The tests added
in https://gcc.gnu.org/g:32d8123cd6ce87acb557aec230e8359051316f9f uses a named
module. My reproducer uses an importable header.

[Bug c++/99631] decltype of non-type template-parameter shouldn't be const

2022-09-25 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99631

--- Comment #5 from Johel Ernesto Guerrero Peña  ---
Would the existing 'wrong-code' work?

> Generates incorrect code. Has to be able to compile and link.

[Bug c++/99631] decltype of non-type template-parameter shouldn't be const

2022-09-25 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99631

--- Comment #6 from Johel Ernesto Guerrero Peña  ---
> But wrong-code isn't really right either [...]

Oh, you already mentioned them. I suggest 'non-conforming-result', or something
more appropriate than "result" to indicate the metaprogrammingness of it.

[Bug c++/107045] New: [modules] ICE on use of std::vector from importable header

2022-09-26 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107045

Bug ID: 107045
   Summary: [modules] ICE on use of std::vector from importable
header
   Product: gcc
   Version: 13.0
Status: UNCONFIRMED
  Keywords: ice-on-valid-code
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: johelegp at gmail dot com
CC: johelegp at gmail dot com
  Target Milestone: ---

See https://godbolt.org/z/qeGb9hhsf.

```sh
CXX=g++
echo "./std.hpp std.gcm
mod mod.gcm" > mm.txt
echo "#include " > std.hpp
echo "export module mod;
import \"std.hpp\";
export std::vector v;" > mod.cpp
$CXX -std=c++23 -fmodules-ts -fmodule-mapper=mm.txt -x c++-header -c std.hpp
$CXX -std=c++23 -fmodules-ts -fmodule-mapper=mm.txt -c mod.cpp
```

Output:
```
mod.cpp:1:8: internal compiler error: in add_binding_entity, at
cp/module.cc:12850
1 | export module mod;
  |^~
0x22c5a9c internal_error(char const*, ...)
???:0
0x9b479b fancy_abort(char const*, int, char const*)
???:0
0xb222f3 walk_module_binding(tree_node*, bitmap_head*, bool (*)(tree_node*,
WMB_Flags, void*), void*)
???:0
0xaf184a depset::hash::add_namespace_entities(tree_node*, bitmap_head*)
???:0
0xb0c2a1 module_state::write_begin(elf_out*, cpp_reader*, module_state_config&,
unsigned int&)
???:0
0xb0d774 finish_module_processing(cpp_reader*)
???:0
0xa96874 c_parse_final_cleanups()
???:0
0xccf5d2 c_common_parse_file()
???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://bugs.archlinux.org/> for instructions.
```

GCC 12/11 fail on import:
```
In module imported at /app/test.cpp:1:1:
mod: error: failed to read compiled module: Bad file data
mod: note: compiled module file is '/app/build/mod.gcm'
mod: fatal error: returning to the gate for a mechanical issue
compilation terminated.
```

[Bug c++/107045] [modules] ICE on use of std::vector from importable header

2022-09-26 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107045

--- Comment #1 from Johel Ernesto Guerrero Peña  ---
Minimal: https://godbolt.org/z/hxrPvPPhs.

```C++
namespace std {
template struct X {
  friend void f();
};
}
```

```C++
export module mod;
import "std.hpp";
export std::X v;
```

[Bug c++/100134] [modules] ICE when using a vector in a module

2022-09-26 Thread johelegp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100134

--- Comment #6 from Johel Ernesto Guerrero Peña  ---
See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107045#c1 for a minimal
reproducer:

Minimal: https://godbolt.org/z/hxrPvPPhs.

```C++
namespace std {
template struct X {
  friend void f();
};
}
```

```C++
export module mod;
import "std.hpp";
export std::X v;
```

  1   2   3   >