Skip to content

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

Closed
@jabelloc

Description

@jabelloc

[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.

Activity

jwakely

jwakely commented on Oct 15, 2020

@jwakely
Member

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

jabelloc commented on Oct 15, 2020

@jabelloc
Author

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

jensmaurer

jensmaurer commented on Oct 15, 2020

@jensmaurer
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

jwakely commented on Oct 15, 2020

@jwakely
Member

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

jwakely commented on Oct 15, 2020

@jwakely
Member

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

jabelloc commented on Oct 15, 2020

@jabelloc
Author

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

jensmaurer

jensmaurer commented on Oct 15, 2020

@jensmaurer
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @jwakely@jabelloc@jensmaurer

        Issue actions

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