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

Overload resolution bug in Clang #480

Open
1 of 2 tasks
h0nzZik opened this issue Jun 19, 2019 · 1 comment
Open
1 of 2 tasks

Overload resolution bug in Clang #480

h0nzZik opened this issue Jun 19, 2019 · 1 comment
Labels
C++ C++ semantics

Comments

@h0nzZik
Copy link
Contributor

h0nzZik commented Jun 19, 2019

Problem description

12.3.3.2/4.2 says:

A conversion that promotes an enumeration whose underlying type is fixed to its underlying type is better than one that promotes to the promoted underlying type, if the two are different.

Therefore, in the following program, the overload resolution should choose the int bar(short) overload.

enum E : short {
	Foo = 1
};

int bar(int) { return 1; }
int bar(short) { return 0; }

int main() {
	return bar(Foo);
}

This is indeed the case for GCC, but Clang reject the program, saying

error: call to 'bar' is ambiguous

The situation is the same when the underlying type of E is char.

What to do

  • fill a bug report for clang
  • test the C++ semantics

Unfortunately, the Clang parser rejects the above program as well. I can see two ways to test the semantics:

  1. Make sure the clang parser outputs kast earlier in the pipeline, before overload resolution happens in Clang. However, this probably goes against our attempt to let the parser emit implicitly-defined functions and template specializations.
  2. Create a manual test case, consisting of two files: test.C.ignore with the source code of the example, and test.C.kast with hand-crafted KAST. The kcc script would be run the test.C.kast file and skip the parsing part.

Btw we should add references to the standard even to our test files.

@h0nzZik h0nzZik added the C++ C++ semantics label Jun 19, 2019
@h0nzZik
Copy link
Contributor Author

h0nzZik commented Jun 19, 2019

The bug report: https://bugs.llvm.org/show_bug.cgi?id=42318

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C++ C++ semantics
Projects
None yet
Development

No branches or pull requests

1 participant