Skip to content
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

Incorrect dependent template name error #17775

Closed
llvmbot opened this issue Sep 29, 2013 · 7 comments
Closed

Incorrect dependent template name error #17775

llvmbot opened this issue Sep 29, 2013 · 7 comments
Labels
bugzilla Issues migrated from bugzilla c++ clang:frontend Language frontend issues, e.g. anything involving "Sema"

Comments

@llvmbot
Copy link
Collaborator

llvmbot commented Sep 29, 2013

Bugzilla Link 17401
Version 3.3
OS All
Reporter LLVM Bugzilla Contributor
CC @DougGregor

Extended Description

In the code shown below, Clang claims that the call to foo within C::baz() is template-dependent and therefore must be prefixed with the template keyword. I'm not a standards expert, but it does not appear to me to be template-dependent -- the call clearly always resolves to A::foo(). Moreover, if the type of C::b is changed to B* and the call becomes b->bar().foo<T>() then no error is reported, which seems pretty suspicious.

Tested on Clang 3.2 (Ubuntu) and Clang 3.3 (Xcode 5).

G++ (4.7, 4.8) does not report an error on this code.

$ cat test.c++
class A {
public:
  template <typename T>
  T foo();
};

class B {
public:
  A bar();
};

template <typename T>
class C {
public:
  T baz() {
    return b.bar().foo<T>();
  }
  
private:
  B b;
};
$ clang++ -c test.c++
test.c++:16:20: error: use 'template' keyword to treat 'foo' as a dependent template name
    return b.bar().foo<T>();
                   ^
                   template 
1 error generated.
$
@llvmbot
Copy link
Collaborator Author

llvmbot commented Jun 29, 2017

@steveire
Copy link
Collaborator

*** Bug llvm/llvm-bugzilla-archive#38299 has been marked as a duplicate of this bug. ***

@steveire
Copy link
Collaborator

mentioned in issue llvm/llvm-bugzilla-archive#38299

@steveire
Copy link
Collaborator

mentioned in issue llvm/llvm-bugzilla-archive#39047

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 9, 2021
@Endilll Endilll added the clang:frontend Language frontend issues, e.g. anything involving "Sema" label Nov 4, 2023
@llvmbot
Copy link
Collaborator Author

llvmbot commented Nov 4, 2023

@llvm/issue-subscribers-clang-frontend

Author: None (llvmbot)

| | | | --- | --- | | Bugzilla Link | [17401](https://llvm.org/bz17401) | | Version | 3.3 | | OS | All | | Reporter | LLVM Bugzilla Contributor | | CC | @DougGregor |

Extended Description

In the code shown below, Clang claims that the call to foo within C::baz() is template-dependent and therefore must be prefixed with the template keyword. I'm not a standards expert, but it does not appear to me to be template-dependent -- the call clearly always resolves to A::foo(). Moreover, if the type of C::b is changed to B* and the call becomes b-&gt;bar().foo&lt;T&gt;() then no error is reported, which seems pretty suspicious.

Tested on Clang 3.2 (Ubuntu) and Clang 3.3 (Xcode 5).

G++ (4.7, 4.8) does not report an error on this code.

$ cat test.c++
class A {
public:
  template &lt;typename T&gt;
  T foo();
};

class B {
public:
  A bar();
};

template &lt;typename T&gt;
class C {
public:
  T baz() {
    return b.bar().foo&lt;T&gt;();
  }
  
private:
  B b;
};
$ clang++ -c test.c++
test.c++:16:20: error: use 'template' keyword to treat 'foo' as a dependent template name
    return b.bar().foo&lt;T&gt;();
                   ^
                   template 
1 error generated.
$

@shafik
Copy link
Collaborator

shafik commented Nov 6, 2023

Related bug: #37647

@shafik
Copy link
Collaborator

shafik commented Nov 6, 2023

Looks fixed in clang10: https://godbolt.org/z/E91qMzf14

@shafik shafik closed this as completed Nov 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla c++ clang:frontend Language frontend issues, e.g. anything involving "Sema"
Projects
None yet
Development

No branches or pull requests

4 participants