| Issue |
115547
|
| Summary |
[clang] "Member access into incomplete type" error is issued by clang but not gcc/MSVC
|
| Labels |
clang
|
| Assignees |
|
| Reporter |
aelovikov-intel
|
I don't know if clang or gcc/MSVC is correct here, so submitting the issue against the compiler that rejects the code. Godbolt link: https://godbolt.org/z/cMbo3drWa.
Same copy-pasted here:
```
#include <type_traits>
template <typename key_t>
struct key_tag {};
template <typename property_ty, typename key_t = property_ty>
struct property_base : key_tag<key_t> {
constexpr auto get_property_impl(key_tag<key_t>) {
return *static_cast<property_ty *>(this);
}
};
template <typename... property_tys>
struct properties : property_tys... {
properties(property_tys... props) : property_tys(props)... {}
using property_tys::get_property_impl...;
template <typename key>
using prop_t = decltype(std::declval<properties>().get_property_impl(key_tag<key>{}));
template <typename key>
static constexpr auto get_property()
-> std::enable_if_t<std::is_empty_v<prop_t<key>>, prop_t<key>> {
return prop_t<key>{};
}
template <typename key>
constexpr auto get_property(int = 0 /* Only needed for MSVC, gcc/clang are fine witout this */)
-> std::enable_if_t<!std::is_empty_v<prop_t<key>>, prop_t<key>> {
return get_property_impl(key_tag<key>{});
}
};
struct foo : property_base<foo> {};
struct bar : property_base<bar> { int x; };
int main() {
properties pl{foo{}, bar{}};
}
```
clang's error:
```
<source>:19:55: error: member access into incomplete type 'properties<foo, bar>'
19 | using prop_t = decltype(std::declval<properties>().get_property_impl(key_tag<key>{}));
| ^
<source>:18:5: note: in instantiation of template type alias 'prop_t' requested here
18 | template <typename key>
| ^
<source>:37:16: note: in instantiation of template class 'properties<foo, bar>' requested here
37 | properties pl{foo{}, bar{}};
| ^
<source>:13:8: note: definition of 'properties<foo, bar>' is not complete until the closing '}'
13 | struct properties : property_tys... {
| ^
1 error generated.
Compiler returned: 1
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs