-
Notifications
You must be signed in to change notification settings - Fork 12.4k
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
[libc++] std::bitset
has non-uglified member typedefs size_type
, difference_type
, and const_reference
causing ambiguity in name lookup
#121618
Comments
std::bitset
has non-conforming member typedefs size_type
, difference_type
, and const_reference
std::bitset
has non-conforming member typedefs size_type
, difference_type
, and const_reference
Which part of the standard are we not conforming to here? |
@philnik777 According to [template.bitset.general], |
No, that describes what public members |
In my opinion, if the standard does not specify a member typedef, the library should try to avoid or minimize the introduction of extra typedefs, especially public ones, to prevent clashes with user-defined classes. From the user's perspective, they have the freedom to utilize any member typedefs not specified by the C++ standards in their own code, which raises my concern. If extra typedefs are deemed necessary, I recommend using a naming convention like |
That's a valid concern, but very different from "non-conforming". |
[objects.within.classes]/3 is arguably related - "equivalent observable behavior" can mean that no additional conflict on (non-reserved) member names is permitted. |
I don't see how. This is about object representation and exposition-only members. This has nothing to do with names in general. |
I tend to think this is not standard-conforming because it causes ambiguity in name lookup. If it were standard conforming, it shouldn't clash with user code, unless the standard itself is defective. This is my personal thought, and you may disagree. While I couldn't find a strong argument regarding whether defining additional non-standard member typedefs (I mean member typedefs that are not specified by the standard, in case you disagree with my expression) is standard-conforming or not, I believe we all agree that defining these additional member typedefs could cause potential clashes with name lookup in user-defined classes. Therefore, the issue is valid. However, I will rephrase the issue to focus only on the name lookup ambiguity caused by these non-uglified typedefs. |
std::bitset
has non-conforming member typedefs size_type
, difference_type
, and const_reference
std::bitset
has non-uglified member typedefs size_type
, difference_type
, and const_reference
causing ambiguity in name lookup
How about [intro.abstract]/5? I don't think this is relaxed for private class members. |
Being non-conforming means that the standard says something we're not conforming to. Whether it's a good idea to do something in a specific way if the standard isn't saying what to do is entirely different - that's QoI. Since we test QoI separately from conformance, that's an important distinction for us.
Are you throwing paragraphs at the wall until one sticks? This is about execution in the abstract machine and has nothing to do with whether we're allowed to provide additional symbols in classes. |
Thank you, @philnik777, for clarifying the distinction between conformance and QoI. Based on your feedback, I have rephrased this issue by removing descriptions regarding standard conformance, and we should have no further disagreements. Since we all agree that resolving the ambiguity issue improves QoI, I will proceed to fix it. I appreciate the discussion and the perspectives you've shared. Thank you, @frederick-vs-ja, for your valuable input and references. Your insights have been instrumental in highlighting the importance of addressing name lookup ambiguities and ensuring our implementation does not cause conflicts with user-defined classes. |
Due to the presence of non-uglified member typedef-names in
std::bitset
, the following program fails to compile in libc++ (while it compiles successfully in libstdc++ and MSVC):https://godbolt.org/z/4EGY13eah
Affected Lines:
llvm-project/libcxx/include/bitset
Lines 170 to 174 in e3dafa8
llvm-project/libcxx/include/bitset
Lines 433 to 436 in e3dafa8
llvm-project/libcxx/include/bitset
Lines 550 to 553 in e3dafa8
llvm-project/libcxx/include/bitset
Line 622 in e3dafa8
Proposed Solution:
In my opinion, if the standard does not specify a member typedef, the library should try to avoid or minimize the introduction of extra typedefs, especially public ones, to prevent potential clashes with user-defined classes, as demonstrated above. From the user's perspective, they have the freedom to utilize any member typedefs not specified by the C++ standards in their own code.
If extra typedefs are deemed necessary, I recommend using a naming convention like
__ugly_name
for those not specified in the standards, as we have previously implemented.The text was updated successfully, but these errors were encountered: