[Bug c++/114311] Possibly wrong "error: ‘this’ is not a constant expression" with consteval member function

2024-03-12 Thread carlo at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114311

--- Comment #5 from Carlo Wood  ---
Hey Andrew :)
You probably mean https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98752
But they are different in that I think that this report is invalid...
See "discussion" here: https://stackoverflow.com/a/78142737/1487069
But I'd definitely like to hear your expert view on it. If it's invalid then
sorry for wasting your time :/.

[Bug c++/114311] Possibly wrong "error: ‘this’ is not a constant expression" with consteval member function

2024-03-11 Thread carlo at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114311

--- Comment #2 from Carlo Wood  ---
I meant `constexpr Symbol x;` inside main - with the same error.

[Bug c++/114311] Possibly wrong "error: ‘this’ is not a constant expression" with consteval member function

2024-03-11 Thread carlo at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114311

Carlo Wood  changed:

   What|Removed |Added

Summary|wrong "error: ‘this’ is not |Possibly wrong "error:
   |a constant expression" with |‘this’ is not a constant
   |consteval member function   |expression" with consteval
   ||member function

--- Comment #1 from Carlo Wood  ---
I stand corrected. When adding `this->` it is still giving an error when trying
to instantiate the template member function.

For example:

```
template
struct SymbolRef { };

struct Symbol {
  int const id_;

  consteval Symbol() : id_(1) { }

  template
  consteval operator SymbolRef() const
  {
return SymbolRefid_>{};
  }
};

int main()
{
  Symbol x;

  static_cast>(x);
}
```

Gives an equivalent error, despite the `this->`.
I am not certain anymore if this is a wrong error.

[Bug c++/114311] New: wrong "error: ‘this’ is not a constant expression" with consteval member function

2024-03-11 Thread carlo at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114311

Bug ID: 114311
   Summary: wrong "error: ‘this’ is not a constant expression"
with consteval member function
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: carlo at gcc dot gnu.org
  Target Milestone: ---

The following snippet:

```
template
struct SymbolRef { };

struct Symbol {
  int const id_;

  consteval Symbol() : id_(1) { }

  template
  consteval operator SymbolRef() const
  {
return SymbolRef{};
  }
};
```

fails with error:

```
source>: In member function 'consteval Symbol::operator SymbolRef() const':
:12:22: error: '*(const Symbol*)this' is not a constant expression
   12 | return SymbolRef{};
  |  ^~~
:12:22: note: in template argument for type 'int'
```

Not a regression.

DOES compile with using `this->id_`.

[Bug middle-end/50481] builtin to reverse the bit order

2022-10-25 Thread carlo at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=50481

Carlo Wood  changed:

   What|Removed |Added

 CC||carlo at gcc dot gnu.org

--- Comment #8 from Carlo Wood  ---
Bump - I need this too ;)

[Bug c++/101405] New: internal compiler error: in reshape_init_class, at cp/decl.c:6483

2021-07-10 Thread carlo at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101405

Bug ID: 101405
   Summary: internal compiler error: in reshape_init_class, at
cp/decl.c:6483
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: carlo at gcc dot gnu.org
  Target Milestone: ---

Invalid code.

struct A {
  int const a = 1;
  int const b = 2;
};

struct B : A {
  using A::a;
  using A::b;
  int const c = 3;
  int const d = 4;
};

int main()
{
  [[maybe_unused]] B b =
  {
  .a = 10,
  .d = 42
  };
}

Result:

prog.cc: In function 'int main()':
prog.cc:19:3: internal compiler error: in reshape_init_class, at cp/decl.c:6483
   19 |   };
  |   ^
0x5ffc9b reshape_init_class
../../source/gcc/cp/decl.c:6483
0x5ffc9b reshape_init_r
../../source/gcc/cp/decl.c:6791
0x6b19ac reshape_init(tree_node*, tree_node*, int)
../../source/gcc/cp/decl.c:6867
0x6b3e12 check_initializer
../../source/gcc/cp/decl.c:7064
0x6c7978 cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int)
../../source/gcc/cp/decl.c:8101
0x7823d7 cp_parser_init_declarator
../../source/gcc/cp/parser.c:22258
0x760a04 cp_parser_simple_declaration
../../source/gcc/cp/parser.c:14801
0x76282d cp_parser_declaration_statement
../../source/gcc/cp/parser.c:13936
0x762ba6 cp_parser_statement
../../source/gcc/cp/parser.c:12066
0x763d2d cp_parser_statement_seq_opt
../../source/gcc/cp/parser.c:12433
0x763de0 cp_parser_compound_statement
../../source/gcc/cp/parser.c:12382
0x78051a cp_parser_function_body
../../source/gcc/cp/parser.c:24448
0x78051a cp_parser_ctor_initializer_opt_and_function_body
../../source/gcc/cp/parser.c:24499
0x78174a cp_parser_function_definition_after_declarator
../../source/gcc/cp/parser.c:30572
0x7828ac cp_parser_function_definition_from_specifiers_and_declarator
../../source/gcc/cp/parser.c:30488
0x7828ac cp_parser_init_declarator
../../source/gcc/cp/parser.c:22020
0x760a04 cp_parser_simple_declaration
../../source/gcc/cp/parser.c:14801
0x78b715 cp_parser_declaration
../../source/gcc/cp/parser.c:14498
0x78c3a6 cp_parser_toplevel_declaration
../../source/gcc/cp/parser.c:14527
0x78c3a6 cp_parser_translation_unit
../../source/gcc/cp/parser.c:4958
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See  for instructions.

Tested on https://wandbox.org/permlink/I8cRHJ2jAk9Op94a