public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/107744] New: Error in constant evaluation of dynamic_cast
@ 2022-11-18 7:34 fchelnokov at gmail dot com
2023-05-19 4:45 ` [Bug c++/107744] " pinskia at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: fchelnokov at gmail dot com @ 2022-11-18 7:34 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107744
Bug ID: 107744
Summary: Error in constant evaluation of dynamic_cast
Product: gcc
Version: 12.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: fchelnokov at gmail dot com
Target Milestone: ---
The following program
struct A {
constexpr A();
virtual void f() {}
bool x;
};
struct B : A {};
constexpr A::A() {
x = dynamic_cast<B*>(this);
}
constexpr bool b = B{}.x;
is accepted by Clang and MSVC, but GCC prints vague error:
<source>:12:24: in 'constexpr' expansion of 'B()'
<source>:7:8: in 'constexpr' expansion of '((B*)this)->B::<anonymous>.A::A()'
<source>:12:24: error: '((&<anonymous>.B::<anonymous>) != 0)' is not a constant
expression
12 | constexpr bool b = B{}.x;
Online demo: https://godbolt.org/z/1xdq68aaM
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c++/107744] Error in constant evaluation of dynamic_cast
2022-11-18 7:34 [Bug c++/107744] New: Error in constant evaluation of dynamic_cast fchelnokov at gmail dot com
@ 2023-05-19 4:45 ` pinskia at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-05-19 4:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107744
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2023-05-19
Ever confirmed|0 |1
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-05-19 4:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-18 7:34 [Bug c++/107744] New: Error in constant evaluation of dynamic_cast fchelnokov at gmail dot com
2023-05-19 4:45 ` [Bug c++/107744] " 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).