Issue 164691
Summary Possible incorrect code generation when using variable templates (again)
Labels new issue
Assignees
Reporter jonas-eschmann
    Hello,

I'm encountering issues with Clang when initializing nested, templated structs again. A similar, now solved issue is filed [here](https://github.com/llvm/llvm-project/issues/60373). 

I was able to boil it down to this:

[https://godbolt.org/z/jvPeYed1x](https://godbolt.org/z/jvPeYed1x)

```c++
template <typename T>
struct A {
    T* a = nullptr;
};

template <typename T>
struct B {
    struct {
        A<T> aa;
    } b;
};


float d[] = {0.1337};
A<float> aa = {d};
B<float> b = {
    {aa},
};

template <typename T>
struct C {
    B<T> b;
};

template <typename T>
T factory = {b};

C<float> c = {b};

int main() {
    return factory<C<float>>.b.b.aa.a == nullptr ? 100 : 0;
    // return c.b.b.aa.a == nullptr ? 100 : 0;
}
```
I expect this to return 0. 

This fails in Clang when using the `factory`. When instantiating C directly it works. 

It fails in all Clang versions but works in GCC and MSVC. 

Tagging the people involved in the previous issue because it seems very similar:
@shafik 
@royjacobson 
@erichkeane

_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to