public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/96593] New: No "declaration changes meaning" diagnostic for alias templates
@ 2020-08-12 17:48 language.lawyer at gmail dot com
2020-08-18 17:06 ` [Bug c++/96593] " mpolacek at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: language.lawyer at gmail dot com @ 2020-08-12 17:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96593
Bug ID: 96593
Summary: No "declaration changes meaning" diagnostic for alias
templates
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Keywords: diagnostic
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: language.lawyer at gmail dot com
Target Milestone: ---
"A name N used in a class S shall refer to the same declaration in its context
and when re-evaluated in the completed scope of S. No diagnostic is required
for a violation of this rule."
The diagnostic for the rule is not required, but since GCC diagnoses some of
the cases, there is a bugreport about missing diagnostic cases (bug 46983), and
the check might become mandatory (will it?), I'd like file this bug.
GCC accepts the code with alias templates:
struct S {};
template <typename>
struct T {};
struct U
{
template<typename>
using S = S;
template<typename>
using T = T<void>;
};
but produces the "declaration changes meaning" error for type aliases.
GCC also diagnoses the case if the "outer" declaration is used before the
corresponding alias template:
struct S {};
struct U
{
S s;
template<typename>
using S = S; // error: declaration of ... changes meaning of 'S'
};
(From https://stackoverflow.com/q/63369264/)
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/96593] No "declaration changes meaning" diagnostic for alias templates
2020-08-12 17:48 [Bug c++/96593] New: No "declaration changes meaning" diagnostic for alias templates language.lawyer at gmail dot com
@ 2020-08-18 17:06 ` mpolacek at gcc dot gnu.org
2021-09-22 9:13 ` gonzalo.gadeschi at gmail dot com
2021-09-22 9:14 ` gonzalo.gadeschi at gmail dot com
2 siblings, 0 replies; 4+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-08-18 17:06 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96593
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mpolacek at gcc dot gnu.org
Status|UNCONFIRMED |NEW
Last reconfirmed| |2020-08-18
Ever confirmed|0 |1
--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Like you say, this might be mandatory in C++23: https://wg21.link/p1697r0. So
confirmed.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/96593] No "declaration changes meaning" diagnostic for alias templates
2020-08-12 17:48 [Bug c++/96593] New: No "declaration changes meaning" diagnostic for alias templates language.lawyer at gmail dot com
2020-08-18 17:06 ` [Bug c++/96593] " mpolacek at gcc dot gnu.org
@ 2021-09-22 9:13 ` gonzalo.gadeschi at gmail dot com
2021-09-22 9:14 ` gonzalo.gadeschi at gmail dot com
2 siblings, 0 replies; 4+ messages in thread
From: gonzalo.gadeschi at gmail dot com @ 2021-09-22 9:13 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96593
gnzlbg <gonzalo.gadeschi at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |gonzalo.gadeschi at gmail dot com
--- Comment #2 from gnzlbg <gonzalo.gadeschi at gmail dot com> ---
*** Bug 102444 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/96593] No "declaration changes meaning" diagnostic for alias templates
2020-08-12 17:48 [Bug c++/96593] New: No "declaration changes meaning" diagnostic for alias templates language.lawyer at gmail dot com
2020-08-18 17:06 ` [Bug c++/96593] " mpolacek at gcc dot gnu.org
2021-09-22 9:13 ` gonzalo.gadeschi at gmail dot com
@ 2021-09-22 9:14 ` gonzalo.gadeschi at gmail dot com
2 siblings, 0 replies; 4+ messages in thread
From: gonzalo.gadeschi at gmail dot com @ 2021-09-22 9:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96593
--- Comment #3 from gnzlbg <gonzalo.gadeschi at gmail dot com> ---
>From 102444 (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102444):
See http://eel.is/c++draft/class.member.lookup#6
[class.member.lookup]/p6: "If it [the result of the search] differs from the
result of a search in T for N from immediately after the class-specifier of T,
the program is ill-formed, no diagnostic required." A class definition is not
allowed to change the meaning of a name that was already used earlier in the
class definition.
While no diagnostic is required, I think a quality implementation like gcc
should produce a diagnostic here and reject this program since it is
ill-formed.
Example (found in the wild): https://gcc.godbolt.org/z/jhEj68Kq8
struct plus {
template<typename... Args>
using invoke = void;
};
template <typename Fn, typename... Args>
using invoke = typename Fn::template invoke<Args...>;
template <typename Fn>
struct compose
{
template <typename X, typename Y>
using F = invoke<Fn, X, Y>;
template <typename X>
using invoke = invoke<Fn, X, X>;
};
using Q = compose<plus>::F<int, int>;
Is accepted by gcc.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-09-22 9:14 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-12 17:48 [Bug c++/96593] New: No "declaration changes meaning" diagnostic for alias templates language.lawyer at gmail dot com
2020-08-18 17:06 ` [Bug c++/96593] " mpolacek at gcc dot gnu.org
2021-09-22 9:13 ` gonzalo.gadeschi at gmail dot com
2021-09-22 9:14 ` gonzalo.gadeschi at gmail dot com
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).