https://bugs.llvm.org/show_bug.cgi?id=52420

            Bug ID: 52420
           Summary: Clang fails to compile valid template for
                    x86_64-pc-windows-msvc target
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected], [email protected]

Originally reported by Anthony Erlinger:

The following valid code fails to compile with -target x86_64-pc-windows-msvc:

template <typename A>
struct S {
    void f() {
        const int B = 5;
        struct C {
            int g() {
                return B; // <-- error: use of undeclared identifier 'B'
            }
        };
    }
};

void test() {
    S<int>().f();
}

Invocation: clang -target x86_64-pc-windows-msvc example.cc

Compiler output:
<source>:7:24: error: use of undeclared identifier 'B'
                return B;
                       ^
<source>:14:14: note: in instantiation of member function 'S<int>::f' requested
here
    S<int>().f();
1 error generated.
Compiler returned: 1

Godbolt example showing failure in clang vs successful compile in MSVC:
https://godbolt.org/z/h6431Wbh5

This is fixed with the flags /Zc:twoPhase or -fno-delayed-template-parsing, but
works in MSVC itself, so it's clearly a bug in how we emulate MSVC's
non-compliant template instantiation.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to