-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
STL: We should _STD qualify _Ugly function calls to avoid ADL #140
Comments
Your
|
That example is compelling, although the thought of changing all I am aware of (apparently) conformant code that instantly destroys any library it comes into contact with, but it is very pathological (e.g. highly poisoned |
I think it's impossible to write a library that is immune to all variations on I've been trying to come up with an example where the library somewhere has to use an infix operator and we supply a class type without making it too contrived. The least-contrived thing I've come up with so far is
Here
I believe it is impossible to accept |
In that case, I think I want the LWG to tell us what to do. |
Richard Smith has brought up similar issues in the past for places we can't fix with qualification, like operator overloads. I don't think there's anything reasonable the library can do to shut this problem down completely but qualifying our |
Which option do we prefer:
I don't list |
Looking at the long list of things attached to this, and:
is there customer value to be gained here given that we are seemingly unable to shut the problem down completely? EDIT: To clarify, this is more about the linked issues being marked as 'duplicates' of this one rather than this change itself. |
We talked about this at the weekly maintainer meeting, and we've decided to qualify (with However, I want to land the Standard Library Modules PR (which modifies many lines of every header) before accepting any PRs that attempt to qualify When we're ready to begin qualifying all such calls, this can be done in one or a handful of headers at a time - a single massive PR updating all headers atomically is not necessary (and would be a pain to review and keep up to date with @CaseyCarter mentioned that we can make a checklist of headers in this issue, when we're ready to begin accepting PRs. |
It's worthwhile to notice that |
This is kind of the crux of my statement above. _STD qualifying all these things is not the absolute ADL defenses the bugs dupe'd to this one are asking for. Saying things like ' |
Partially addresses microsoft#140
Partially addresses microsoft#140
Partially addresses microsoft#140
This is failing even after #3148. The problem is that there are intentional ADL
|
I don't think this is solvable, unless we change the standard wording to restrict ADL for |
That would actually be philosophically safe (because non-enum/class types are primitive and therefore don't require any special swap semantics)... but at the same time it wouldn't be enough to solve the problem! Consider I note that my first comment on this issue #140 (comment) was about |
I think there should be a way to test |
#include <iostream>
#include <ranges>
using namespace std;
struct inc;
template<class T> struct wrp { T t; };
using inp = wrp<inc>*;
int main()
{
inp a{}, b{};
_RANGES swap(a, b); // ok...
using pr = std::pair<inp, inp>;
pr c{}, d{};
// _RANGES swap(c, d); // no...
} I'm curious, what's the advantage of |
Currently no implementation accepts this example due to ADL in the comparison of iterators (Godbolt link). However, the standard doesn't seem to state that this is UB/ill-formed. #include <vector>
struct incomplete;
template<class T>
struct holder { T t; };
int main()
{
std::vector<holder<incomplete>*> v{};
v.emplace_back();
} It seems that iterators of standard containers shouldn't be implemented as class templates, and we can't fix this without breaking ABI. |
2. Use the _Intermediate_result Only when the intermediate type is different with output type
See "ADL can interfere even with uglified names" by Arthur O'Dwyer.
We've survived 20+ years with unqualified
_Ugly
function calls, but perhaps we should consider changing this. It's possible that this could improve throughput.List of headers to process, as mentioned in #140 (comment) below (
cvt
subtree intentionally omitted):__msvc_all_public_headers.hpp
__msvc_chrono.hpp
__msvc_format_ucd_tables.hpp
__msvc_int128.hpp
__msvc_iter_core.hpp
__msvc_system_error_abi.hpp
__msvc_tzdb.hpp
__msvc_xlocinfo_types.hpp
algorithm
any
array
atomic
barrier
bit
bitset
cassert
ccomplex
cctype
cerrno
cfenv
cfloat
charconv
chrono
cinttypes
ciso646
climits
clocale
cmath
codecvt
compare
complex
concepts
condition_variable
coroutine
csetjmp
csignal
cstdalign
cstdarg
cstdbool
cstddef
cstdint
cstdio
cstdlib
cstring
ctgmath
ctime
cuchar
cwchar
cwctype
deque
exception
execution
expected
experimental/coroutine
experimental/deque
experimental/filesystem
experimental/forward_list
experimental/generator
experimental/list
experimental/map
experimental/resumable
experimental/set
experimental/string
experimental/unordered_map
experimental/unordered_set
experimental/vector
filesystem
format
forward_list
fstream
functional
future
hash_map
hash_set
initializer_list
iomanip
ios
iosfwd
iostream
iso646.h
istream
iterator
latch
limits
list
llll
locale
map
memory
memory_resource
mutex
new
numbers
numeric
optional
ostream
queue
random
ranges
ratio
regex
scoped_allocator
semaphore
set
shared_mutex
source_location
span
spanstream
sstream
stack
stacktrace
stdatomic.h
stdexcept
stop_token
streambuf
string
string_view
strstream
syncstream
system_error
thread
tuple
type_traits
typeindex
typeinfo
unordered_map
unordered_set
use_ansi.h
utility
valarray
variant
(_STD
-qualify_Ugly
non-member function calls in<variant>
#3148)vector
version
xatomic.h
xatomic_wait.h
xbit_ops.h
xcall_once.h
xcharconv.h
xcharconv_ryu.h
xcharconv_ryu_tables.h
xcharconv_tables.h
xerrc.h
xfacet
xfilesystem_abi.h
xhash
xiosbase
xkeycheck.h
xlocale
xlocbuf
xlocinfo
xlocmes
xlocmon
xlocnum
xloctime
xmemory
xnode_handle.h
xpolymorphic_allocator.h
xsmf_control.h
xstddef
xstring
xthreads.h
xtimec.h
xtr1common
xtree
xutility
ymath.h
yvals.h
yvals_core.h
The text was updated successfully, but these errors were encountered: