[Bug c++/118249] Misdiagnosing use of 'this' while doing class member access in constant evaluation

2026-06-11 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118249

Richard Biener  changed:

   What|Removed |Added

   Target Milestone|15.3|15.4

--- Comment #8 from Richard Biener  ---
GCC 15.3 is being released, retargeting bugs to GCC 15.4.

[Bug c++/118249] Misdiagnosing use of 'this' while doing class member access in constant evaluation

2025-08-08 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118249

Richard Biener  changed:

   What|Removed |Added

   Target Milestone|15.2|15.3

--- Comment #7 from Richard Biener  ---
GCC 15.2 is being released, retargeting bugs to 15.3.

[Bug c++/118249] Misdiagnosing use of 'this' while doing class member access in constant evaluation

2025-04-25 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118249

Jakub Jelinek  changed:

   What|Removed |Added

   Target Milestone|15.0|15.2

--- Comment #6 from Jakub Jelinek  ---
GCC 15.1 is being released, retargeting bugs to GCC 15.2.

[Bug c++/118249] Misdiagnosing use of 'this' while doing class member access in constant evaluation

2025-04-07 Thread ppalka at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118249

Patrick Palka  changed:

   What|Removed |Added

 Ever confirmed|0   |1
 Resolution|FIXED   |---
 Status|RESOLVED|NEW
   Last reconfirmed||2025-04-07

--- Comment #5 from Patrick Palka  ---
Reopening as this is not fully fixed as Barry pointed out in PR117849#c12:

template 
struct Array {
constexpr int size() const { return N; }
};

struct A {
Array a;

void f() {
static_assert(a.size() == 4); // ok
}
};

struct B {
Array* p;

void f() {
static_assert(p->size() == 4); // error (expected) 
}
};

struct C {
Array& r;

void f() {
static_assert(r.size() == 4); // error (unexpected?)
}
};

struct D {
Array& r;

void f() {
Array& local = r;
static_assert(local.size() == 4); // error (unexpected?)
}
};

[Bug c++/118249] Misdiagnosing use of 'this' while doing class member access in constant evaluation

2025-04-05 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118249

Andrew Pinski  changed:

   What|Removed |Added

 CC||rdiez-2006 at rd10 dot de

--- Comment #4 from Andrew Pinski  ---
*** Bug 117700 has been marked as a duplicate of this bug. ***

[Bug c++/118249] Misdiagnosing use of 'this' while doing class member access in constant evaluation

2025-04-05 Thread ppalka at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118249

Patrick Palka  changed:

   What|Removed |Added

 CC||ppalka at gcc dot gnu.org
 Resolution|--- |FIXED
   Assignee|unassigned at gcc dot gnu.org  |ppalka at gcc dot 
gnu.org
   Target Milestone|--- |15.0
 Status|UNCONFIRMED |RESOLVED

--- Comment #3 from Patrick Palka  ---
Fixed for GCC 15

[Bug c++/118249] Misdiagnosing use of 'this' while doing class member access in constant evaluation

2025-04-05 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118249

--- Comment #2 from GCC Commits  ---
The master branch has been updated by Patrick Palka :

https://gcc.gnu.org/g:f60570b26446781c0205981804f6aa4ff1708b12

commit r15-9226-gf60570b26446781c0205981804f6aa4ff1708b12
Author: Patrick Palka 
Date:   Sat Apr 5 15:22:48 2025 -0400

c++: harmless use of 'this' rejected despite P2280R4 [PR118249]

Here the implicit use of 'this' in inner.size() template argument was
being rejected despite P2280R4 relaxations, due to the special *this
handling in the INDIRECT_REF case of potential_constant_expression_1.

This handling was originally added by r196737 as part of fixing PR56481,
and it seems obsolete especially in light of P2280R4.  There doesn't
seem to be a good reason that we need to handle *this specially from
other dereferences.

This patch therefore removes this special handling.  As a side benefit
we now correctly reject some *reinterpret_cast<...>(...) constructs
earlier, via p_c_e_1 rather than via constexpr evaluation (because the
removed STRIP_NOPS step meant we'd overlook such casts), which causes a
couple of diagnostic changes (for the better).

PR c++/118249

gcc/cp/ChangeLog:

* constexpr.cc (potential_constant_expression_1)
: Remove obsolete *this handling.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/constexpr-reinterpret2.C: Expect error at
call site of the non-constexpr functions.
* g++.dg/cpp23/constexpr-nonlit12.C: Likewise.
* g++.dg/cpp0x/constexpr-ref14.C: New test.

Reviewed-by: Jason Merrill 

[Bug c++/118249] Misdiagnosing use of 'this' while doing class member access in constant evaluation

2024-12-30 Thread barry.revzin at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118249

--- Comment #1 from Barry Revzin  ---
Pretend the example had declared outer as

extern array<10>& outer;

Since otherwise the usage has nothing to do with P2280. gcc does correctly
allow that case too.