public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/109340] New: Inconsistent diagnostics for invalid member types in union
@ 2023-03-29 20:55 redi at gcc dot gnu.org
2023-03-29 23:38 ` [Bug c++/109340] " cvs-commit at gcc dot gnu.org
2023-03-29 23:41 ` redi at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2023-03-29 20:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109340
Bug ID: 109340
Summary: Inconsistent diagnostics for invalid member types in
union
Product: gcc
Version: 13.0
Status: UNCONFIRMED
Keywords: diagnostic
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: redi at gcc dot gnu.org
Target Milestone: ---
template<typename T>
union U
{
U();
T t;
};
U<int&> ref;
U<int[]> arr;
U<int()> func;
G++ correctly rejects this, but has three very different errors for basically
the same problem:
union.cc: In instantiation of ‘union U<int&>’:
union.cc:9:9: required from here
union.cc:6:5: error: non-static data member ‘U<int&>::t’ in a union may not
have reference type ‘int&’
6 | T t;
| ^
union.cc: In instantiation of ‘union U<int []>’:
union.cc:10:10: required from here
union.cc:6:5: error: flexible array member ‘U<T>::t’ in union
union.cc: In instantiation of ‘union U<int()>’:
union.cc:11:10: required from here
union.cc:6:5: error: data member ‘U<int()>::t’ invalidly declared function type
Specifically:
error: non-static data member ‘U<int&>::t’ in a union may not have reference
type ‘int&’
error: flexible array member ‘U<T>::t’ in union
error: data member ‘U<int()>::t’ invalidly declared function type
Could we use the same phrasing for all three?
The first one seems the best, and the third one seems the worst.
For comparison, Clang says:
union.cc:6:5: error: union member 't' has reference type 'int &'
T t;
^
union.cc:9:9: note: in instantiation of template class 'U<int &>' requested
here
U<int&> ref;
^
union.cc:6:5: error: data member instantiated with function type 'int ()'
T t;
^
union.cc:11:10: note: in instantiation of template class 'U<int ()>' requested
here
U<int()> func;
^
2 errors generated.
Not very good either.
EDG says:
"union.cc", line 6: error: incomplete type is not allowed
T t;
^
detected during instantiation of union "U<T> [with T=int []]" at line
10
"union.cc", line 6: error: a function type is not allowed here
T t;
^
detected during instantiation of union "U<T> [with T=int ()]" at line
11
2 errors detected in the compilation of "union.cc".
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/109340] Inconsistent diagnostics for invalid member types in union
2023-03-29 20:55 [Bug c++/109340] New: Inconsistent diagnostics for invalid member types in union redi at gcc dot gnu.org
@ 2023-03-29 23:38 ` cvs-commit at gcc dot gnu.org
2023-03-29 23:41 ` redi at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-03-29 23:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109340
--- Comment #1 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>:
https://gcc.gnu.org/g:31a909712014b75fc6ae2ca5eaa425f218bb5f32
commit r13-6934-g31a909712014b75fc6ae2ca5eaa425f218bb5f32
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Wed Mar 29 22:16:55 2023 +0100
libstdc++: Use std::remove_cv_t in std::optional::transform [PR109340]
We need to strip cv-qualifiers from the result of the callable passed to
std::optional::transform.
For std::expected::transform and std::expected::transform_error I
noticed we were stripping cv-qualifiers but were also incorrectly
stripping references.
libstdc++-v3/ChangeLog:
PR libstdc++/109340
* include/std/expected (expected::transform): Use
std::remove_cv_t instead of std::remove_cvref_t.
(expected::transform_error): Likewise.
(expected<cv void, E>::transform): Likewise.
(expected<cv void, E>::transform_error): Likewise.
* include/std/optional (transform): Use std::remove_cv_t.
* testsuite/20_util/optional/monadic/pr109340.cc: New test.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/109340] Inconsistent diagnostics for invalid member types in union
2023-03-29 20:55 [Bug c++/109340] New: Inconsistent diagnostics for invalid member types in union redi at gcc dot gnu.org
2023-03-29 23:38 ` [Bug c++/109340] " cvs-commit at gcc dot gnu.org
@ 2023-03-29 23:41 ` redi at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2023-03-29 23:41 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109340
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Gah, wrong ID in that commit message.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-03-29 23:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-29 20:55 [Bug c++/109340] New: Inconsistent diagnostics for invalid member types in union redi at gcc dot gnu.org
2023-03-29 23:38 ` [Bug c++/109340] " cvs-commit at gcc dot gnu.org
2023-03-29 23:41 ` 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).