public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/106313] New: GCC incorrectly compiles code involving concept
@ 2022-07-15 11:19 jlame646 at gmail dot com
2022-07-15 12:07 ` [Bug c++/106313] " redi at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: jlame646 at gmail dot com @ 2022-07-15 11:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106313
Bug ID: 106313
Summary: GCC incorrectly compiles code involving concept
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: jlame646 at gmail dot com
Target Milestone: ---
The following program is compiled in gcc 12.1 even though it should not as
`obj` is not a constant expression. A working demo can be seen
here:https://godbolt.org/z/aqoMGazfd
```
template<bool op>
class Person
{
const bool own_pet;
public:
Person() : own_pet(op) {}
consteval bool OwnPet() const { return own_pet; }
consteval bool OwnPetC() const { return true; }
void PatPet() const {}
};
template<typename T>
concept MustOwnPet = requires(T obj) {
requires obj.OwnPet();
};
void pat(const MustOwnPet auto& p)
{
p.PatPet();
}
template<typename T>
concept MustOwnPetC = requires(T obj) {
requires obj.OwnPetC();
};
void pat_c(const MustOwnPetC auto& p)
{
p.PatPet();
}
int main()
{
pat_c(Person<true>());
return 0;
}
```
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-07-15 12:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-15 11:19 [Bug c++/106313] New: GCC incorrectly compiles code involving concept jlame646 at gmail dot com
2022-07-15 12:07 ` [Bug c++/106313] " redi at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).