<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/57019>57019</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
False positive dependent template name
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
cloudhan
</td>
</tr>
</table>
<pre>
The following code snippet fails with
```
<source>:31:5: error: use 'template' keyword to treat 'Ptr' as a dependent template name
o.Ptr<T>();
^
template
1 error generated.
ASM generation compiler returned: 1
<source>:31:5: error: use 'template' keyword to treat 'Ptr' as a dependent template name
o.Ptr<T>();
^
template
1 error generated.
Execution build compiler returned: 1
```
But if you compile with `-DFIX1` or `-DFIX2`, it will workaround the error and compile smoothly. I don't see the `o` object being something dependent on a template parameter. So the `o.Ptr<T>();` should be fine here. So I think this is a false positive (even MSVC can compile it!). I haven't passed the bar examination of C++, so please kindly point me out if I am wrong here.
https://godbolt.org/z/rv3nTzxvP
```cpp
#include <cstdint>
#include <vector>
class Var final {
public:
template <typename T>
T* Ptr() { return nullptr; }
};
class Context {
public:
Var* Output(const std::vector<int64_t>&) { return nullptr; }
};
template<typename T>
class Op {
public:
void Compute(Context* ctx);
int64_t v;
};
template<typename T>
void Op<T>::Compute(Context* ctx) {
#if defined(FIX1)
Var& o = *ctx->Output({this->v});
#elif defined(FIX2)
auto& o = *ctx->Output({int64_t(this->v)});
#else
auto& o = *ctx->Output({this->v});
#endif
o.Ptr<T>();
}
int main() {
Context ctx{};
Op<float> o{};
o.Compute(&ctx);
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzdVU1v2zgQ_TXyZRBDH7EsHXRInATIoUiBBMXeFpQ4srihSYGknLi_foeUZTlpmt32WECS-Tnz5r2Zca35oXrqEFotpX4RaguN5ghWib5HBy0T0sKLcF0U30TxVZTHx2ecZhurB9NglN1G2VWW0GdFL6Ax2vjBYBGid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