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

candidate function chosen improperly in type dependent context #7768

Closed
llvmbot opened this issue Jun 17, 2010 · 3 comments
Closed

candidate function chosen improperly in type dependent context #7768

llvmbot opened this issue Jun 17, 2010 · 3 comments
Labels
bugzilla Issues migrated from bugzilla clang:frontend Language frontend issues, e.g. anything involving "Sema" wontfix Issue is real, but we can't or won't fix it. Not invalid

Comments

@llvmbot
Copy link
Collaborator

llvmbot commented Jun 17, 2010

Bugzilla Link 7396
Resolution WONTFIX
Resolved on Jun 12, 2012 22:26
Version trunk
OS Linux
Reporter LLVM Bugzilla Contributor
CC @chandlerc,@zygoloid

Extended Description

Clang (and gcc and comeau) accept the following invalid program:

static void test1(int *) { }

template
int *test2(const T &) { return 0; }

template
void test3(const T &t) {
test1(test2(t));
}

The statement "test1(test2(t))" is type-dependent all the way through to test1. 14.6.4.2/1 second bullet states:
"For the part of the lookup using associated namespace (3.4.2), only function declarations with external linkage found in either the template definition context or the template instantiation context are found."

test1() does not have external linkage. If we remove 'static' or change test1 to ::test1 (see the rest of the referenced section) then the program becomes valid.

@chandlerc
Copy link
Member

Clang (and gcc and comeau) accept the following invalid program:

static void test1(int *) { }

template
int *test2(const T &) { return 0; }

template
void test3(const T &t) {
test1(test2(t));
}

The statement "test1(test2(t))" is type-dependent all the way through to test1.
14.6.4.2/1 second bullet states:
"For the part of the lookup using associated namespace (3.4.2), only function
declarations with external linkage found in either the template definition
context or the template instantiation context are found."

Just to clarify, the first bullet is the one that governs from 14.6.4.2/1, but it too restricts to functions with external linkage.

test1() does not have external linkage. If we remove 'static' or change test1
to ::test1 (see the rest of the referenced section) then the program becomes
valid.

@llvmbot
Copy link
Collaborator Author

llvmbot commented Jun 17, 2010

And this is fixed in C++0x, which says:

"— For the part of the lookup using unqualified name lookup (3.4.1), only function declarations from the
template definition context are found.

— For the part of the lookup using associated namespaces (3.4.2), only function declarations found in
either the template definition context or the template instantiation context are found. "

@zygoloid
Copy link
Mannequin

zygoloid mannequin commented Jun 13, 2012

This was CWG issue 561, and I think it's reasonable to consider this a bug in C++98 rather than a bug in Clang :)

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
@Quuxplusone Quuxplusone added the wontfix Issue is real, but we can't or won't fix it. Not invalid label Jan 20, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla clang:frontend Language frontend issues, e.g. anything involving "Sema" wontfix Issue is real, but we can't or won't fix it. Not invalid
Projects
None yet
Development

No branches or pull requests

3 participants