public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/106291] New: Literal class can appear in the constant-expression of a declaration of a bit-field
@ 2022-07-14 5:14 xmh970252187 at gmail dot com
2022-07-14 5:14 ` [Bug c++/106291] " xmh970252187 at gmail dot com
2022-07-14 5:20 ` pinskia at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: xmh970252187 at gmail dot com @ 2022-07-14 5:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106291
Bug ID: 106291
Summary: Literal class can appear in the constant-expression of
a declaration of a bit-field
Product: gcc
Version: 13.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: xmh970252187 at gmail dot com
Target Milestone: ---
struct A{
constexpr operator int(){
return 8;
}
};
struct B{
int a:A{};
};
GCC rejects this example, with a diagnosis that
> error: width of bit-field 'a' has non-integral type 'A'
[expr.const] p9 explicitly permit this case.
> If an expression of literal class type is used in a context where an integral constant expression is required, then that expression is contextually implicitly converted ([conv]) to an integral or unscoped enumeration type and the selected conversion function shall be constexpr.
Clang accepts this example
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/106291] Literal class can appear in the constant-expression of a declaration of a bit-field
2022-07-14 5:14 [Bug c++/106291] New: Literal class can appear in the constant-expression of a declaration of a bit-field xmh970252187 at gmail dot com
@ 2022-07-14 5:14 ` xmh970252187 at gmail dot com
2022-07-14 5:20 ` pinskia at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: xmh970252187 at gmail dot com @ 2022-07-14 5:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106291
--- Comment #1 from jim x <xmh970252187 at gmail dot com> ---
https://godbolt.org/z/x5hPe5qoP
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/106291] Literal class can appear in the constant-expression of a declaration of a bit-field
2022-07-14 5:14 [Bug c++/106291] New: Literal class can appear in the constant-expression of a declaration of a bit-field xmh970252187 at gmail dot com
2022-07-14 5:14 ` [Bug c++/106291] " xmh970252187 at gmail dot com
@ 2022-07-14 5:20 ` pinskia at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-07-14 5:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106291
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |DUPLICATE
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup of bug 83929.
*** This bug has been marked as a duplicate of bug 83929 ***
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-07-14 5:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-14 5:14 [Bug c++/106291] New: Literal class can appear in the constant-expression of a declaration of a bit-field xmh970252187 at gmail dot com
2022-07-14 5:14 ` [Bug c++/106291] " xmh970252187 at gmail dot com
2022-07-14 5: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).