-
Notifications
You must be signed in to change notification settings - Fork 251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Type-scope object alias can't have deduced type or use CTAD #700
Comments
Title: Type-scope object alias can't have deduced type. Description: This is what I used before commit b589f5d. Minimal reproducer (https://cpp2.godbolt.org/z/jhnjWPY76):
Commands:cppfront main.cpp2
clang++17 -std=c++23 -stdlib=libc++ -lc++abi -pedantic-errors -Wall -Wextra -Wconversion -Werror=unused-result -I . main.cpp Expected result: public: static const auto arr1 = std::array{0}; Actual result and error: //=== Cpp2 type definitions and function declarations ===========================
public: static const auto arr1;// error.
//=== Cpp2 function definitions =================================================
inline constexpr auto t::arr1 = std::array{0}; Cpp2 lowered to Cpp1://=== Cpp2 type declarations ====================================================
#include "cpp2util.h"
class t;
//=== Cpp2 type definitions and function declarations ===========================
#include <array>
auto inline constexpr arr0 = std::array{0};// OK.
class t {
public: static const auto arr1;// error.
};
auto main() -> int;
//=== Cpp2 function definitions =================================================
inline constexpr auto t::arr1 = std::array{0};
auto main() -> int{}
|
One limitation of first declaring and then defining a type-scope object alias |
I think that means that a templated
|
Looks like the limitation was known. |
Interim ack: In the meantime I'll add a diagnostic for an object alias in a nested type, which isn't currently supported. Thanks! |
This comment was marked as off-topic.
This comment was marked as off-topic.
It actually doesn't. |
According to Brian Bi at https://cpplang.slack.com/archives/C21PKDHSL/p1696124673621459?thread_ts=1695800824.887719&cid=C21PKDHSL:
So it seems those are just compiler bugs. |
Thanks!
Right, and because Clang 3.4 is so old I just assumed that by now it would have been fixed. But it seems it's a rare enough case that it hasn't. Thank you very much for following up on this! |
This is troublesome to determine.
The heuristics of #706 are that those are defined in class.
|
This is a limitation of Cppfront. A simpler heuristic that should always works Done in #706. |
Title: Can't use CTAD for type-scope object alias.
Minimal reproducer (https://cpp2.godbolt.org/z/63occKT7x):
Commands:
cppfront main.cpp2 clang++17 -std=c++23 -stdlib=libc++ -lc++abi -pedantic-errors -Wall -Wextra -Wconversion -Werror=unused-result -I . main.cpp
Expected result:
A definitely not-incomplete object type
to be defined in the class' body.
Actual result and error:
Cpp2 lowered to Cpp1:
See also:
in
parameter passing (restore old behavior, exclude problem cases only) #666 for more of "definitely not-incomplete object type".The text was updated successfully, but these errors were encountered: