Unqualified name use causes ambiguity through ADL

I have a library that redefines forward_as_tuple in its namespace, along with some concrete types. This causes the problem with the following code:

https://github.com/llvm/llvm-project/blob/master/libcxx/include/tuple#L1352

https://github.com/llvm/llvm-project/blob/master/libcxx/include/tuple#L1367

Here, forward_as_tuple is being called unqualified, and ADL kicks in. ADL finds the definition of forward_as_tuple in the library that I am using, and I get ambiguity.

It definitely can be argued that the library I am using makes a dangerous choice by sticking concrete types into the same namespace as the template forward_as_tuple, but it does. My question is why libc++ calls forward_as_tuple unqualified rather than std::forward_as_tuple. Is this a bug, or is there a good reason for this?

Thanks,
Marcin

I have a library that redefines forward_as_tuple in its namespace, along with some concrete types. This causes the problem with the following code:

https://github.com/llvm/llvm-project/blob/master/libcxx/include/tuple#L1352

https://github.com/llvm/llvm-project/blob/master/libcxx/include/tuple#L1367

Here, forward_as_tuple is being called unqualified, and ADL kicks in. ADL finds the definition of forward_as_tuple in the library that I am using, and I get ambiguity.

It definitely can be argued that the library I am using makes a dangerous choice by sticking concrete types into the same namespace as the template forward_as_tuple, but it does. My question is why libc++ calls forward_as_tuple unqualified rather than std::forward_as_tuple. Is this a bug, or is there a good reason for this?

This is a bug in libc++.

Apart from customization points like swap, libc++ should never use ADL, even when calling functions with reserved names.

I’m working on a Clang tool to clean up ADL-using call expressions. I’ll run it over libc++

Thanks Eric. I guess this could use a bug report. I searched existing bug reports, but I did not find anything about it. Are you involved in development of libc++?

Thank you,
Marcin