public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/107165] New: Downcasting in constexpr, error: "accessing value of `...Derived::<anonymous>’ through a ‘Derived’ glvalue in a constant expression"
@ 2022-10-05 23:09 petr.azmanov at wartsila dot com
2022-10-05 23:15 ` [Bug c++/107165] " pinskia at gcc dot gnu.org
2022-10-05 23:20 ` pinskia at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: petr.azmanov at wartsila dot com @ 2022-10-05 23:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107165
Bug ID: 107165
Summary: Downcasting in constexpr, error: "accessing value of
`...Derived::<anonymous>’ through a ‘Derived’ glvalue
in a constant expression"
Product: gcc
Version: 11.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: petr.azmanov at wartsila dot com
Target Milestone: ---
Created attachment 53670
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53670&action=edit
copy of the test case from the comment
Downcasting in constexpr context is broken if derived class is wrapped in
another structure.
Tested locally with g++ (Ubuntu 11.2.0-19ubuntu1) 11.2.0
Reproduced with g++ 11.3.0 in Godbolt (https://godbolt.org/z/fvoWhrh41)
Isn't reproduced with 12.1 or 12.2.
```
struct Base
{
int b = 0;
};
struct Derived : Base
{
int d = 2;
constexpr bool foo(int x)
{
return x > d;
}
};
int main()
{
constexpr auto test = []()
{
struct Dummy
{
Derived derived;
};
Dummy d;
Base & base = d.derived;
static_cast<Derived &>(base).foo(1);
// Derived d;
// Base & base = d;
// static_cast<Derived &>(base).foo(1);
return true;
}();
return test;
}
```
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/107165] Downcasting in constexpr, error: "accessing value of `...Derived::<anonymous>’ through a ‘Derived’ glvalue in a constant expression"
2022-10-05 23:09 [Bug c++/107165] New: Downcasting in constexpr, error: "accessing value of `...Derived::<anonymous>’ through a ‘Derived’ glvalue in a constant expression" petr.azmanov at wartsila dot com
@ 2022-10-05 23:15 ` pinskia at gcc dot gnu.org
2022-10-05 23:20 ` pinskia at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-10-05 23:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107165
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note since it was fixed in GCC 12.1.0 and it does not look like a regression,
this will be closed as fixed for GCC 12 after bisecting to the patch which
fixed it and the fix won't be backported to GCC 11.x.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/107165] Downcasting in constexpr, error: "accessing value of `...Derived::<anonymous>’ through a ‘Derived’ glvalue in a constant expression"
2022-10-05 23:09 [Bug c++/107165] New: Downcasting in constexpr, error: "accessing value of `...Derived::<anonymous>’ through a ‘Derived’ glvalue in a constant expression" petr.azmanov at wartsila dot com
2022-10-05 23:15 ` [Bug c++/107165] " pinskia at gcc dot gnu.org
@ 2022-10-05 23:20 ` pinskia at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-10-05 23:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107165
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |DUPLICATE
Status|UNCONFIRMED |RESOLVED
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup of bug 103879.
See bug 103879 comment #6 which is exactly the same testcase as comment #0
here.
*** This bug has been marked as a duplicate of bug 103879 ***
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-10-05 23:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-05 23:09 [Bug c++/107165] New: Downcasting in constexpr, error: "accessing value of `...Derived::<anonymous>’ through a ‘Derived’ glvalue in a constant expression" petr.azmanov at wartsila dot com
2022-10-05 23:15 ` [Bug c++/107165] " pinskia at gcc dot gnu.org
2022-10-05 23:20 ` pinskia 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).