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

Paragraphs 2 and 6 of [basic.type.qualifier] appear to be in contradiction (emphases are mine) #4297

Closed
jabelloc opened this issue Oct 15, 2020 · 7 comments

Comments

@jabelloc
Copy link

jabelloc commented Oct 15, 2020

[basic.type.qualifier]/2:

Except for array types, a compound type ([basic.compound]) is not cv-qualified by the cv-qualifiers (if any) of the types from which it is compounded.

[basic.type.qualifier]/6:

In this document, the notation cv (or cv1, cv2, etc.) , used in the description of types, represents an arbitrary set of cv-qualifiers, i.e., one of {const}, {volatile}, {const, volatile}, or the empty set. For a type cv T, the top-level cv-qualifiers of that type are those denoted by cv.

[Example 2: The type corresponding to the type-id const int& has no top-level cv-qualifiers. The type corresponding to the type-id volatile int * const has the top-level cv-qualifier const. For a class type C, the type corresponding to the type-id void (C​::​* volatile)(int) const has the top-level cv-qualifier volatile. — end example]

Note : According to [basic.compound]/(1.3) and (1.8), both pointers and pointers to member are compound types.

@jwakely
Copy link
Member

jwakely commented Oct 15, 2020

There is no contradiction. The first example in p6 is saying that the top-level qualifier on the compound type is const, it is not affected by the volatile qualifier on the type volatile int. The second example is saying that the top-level qualifier on the compound type is volatile, it is not affected by the const qualifier on the function type void (int) const. Both examples perfectly agree with p2.

@jabelloc
Copy link
Author

Ok I see what you mean. But what does it mean a volatile pointer to a member function of type void(int)?

@jensmaurer
Copy link
Member

Exactly that: a pointer-to-member is just some (special) data type, and that type can be volatile-qualified, as-if it were a volatile int.

@jwakely
Copy link
Member

jwakely commented Oct 15, 2020

But what does it mean a volatile pointer to a member function of type void(int)?

using PMF = void (C::*)(int) const;
PMF pmf = &C::foo;
volatile PMF vol_pmf = pmf;

@jwakely
Copy link
Member

jwakely commented Oct 15, 2020

I really think this kind of thing belongs on StackOverflow. Instead of telling us there's a flaw in the standard, you could ask on StackOverflow why the wording seems contradictory. This could be clarified there, and so could your follow-up question about what the volatile-qualified type means.

@jabelloc
Copy link
Author

Well if that's what you prefer, definitely I'll stop posting issues here. Thanks for your kind attention. Good luck!

@jensmaurer
Copy link
Member

"what does it mean"

The same what it means to have a volatile T for any other (scalar) T.

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

No branches or pull requests

3 participants