Skip to content

Inconsistent class-key in class template declarations #534

Closed

Description

@Arcoth

Declarations such as e.g.

// 20.3.4, tuple-like access to pair:
template <class T> class tuple_size;
template <size_t I, class T> class tuple_element;

template <class T1, class T2> struct tuple_size<pair<T1, T2> >;
template <class T1, class T2> struct tuple_element<0, pair<T1, T2> >;
template <class T1, class T2> struct tuple_element<1, pair<T1, T2> >;

Use struct and class interchangeably. While this is not a defective thing per se (see §7.1.6.3/3), compilers do warn about inconsistent usage of both and it should be tidied up.

Activity

  1. jwakely commented on Aug 27, 2015

    @jwakely
    Member

    Compilers don't compile declarations in the standard.

  2. Arcoth commented on Aug 27, 2015

    @Arcoth
    ContributorAuthor

    My point is that the aforementioned usage can be irritating. Also, yes they do, as the declarations are put into headers by compiler-devs that themselves are compiled when including them - unless I'm mistaken? (Of course, standard headers don't produce warnings, but a specialization of tuple_size necessarily does, which is annoying!)

  3. jwakely commented on Aug 27, 2015

    @jwakely
    Member

    Compilers do not compile the standard, they compile headers that come with their implementation. The implementation headers can use whatever class-keys they want to, they don't have to match the standard, and changing the standard doesn't mean implementations will change.
    I see nothing worth fixing here.

  4. oblitum commented on Aug 27, 2015

    @oblitum

    Nor do I, I use class and struct interchangeably (I don't like class with struct-like layout for example, with no private members, etc). If any compiler I use were to warn about that I would just use a compiler flag to silence such warning.

  5. sigfpe commented on Aug 27, 2015

    @sigfpe

    Users who tolerate those bogus warnings should find something more productive to do.

    -------- Original message --------
    From: Francisco Lopes notifications@github.com
    Date: 08/27/2015 9:54 AM (GMT-08:00)
    To: cplusplus/draft draft@noreply.github.com
    Subject: Re: [draft] Inconsistent class-key in class template declarations
    (#534)

    Nor do I, I use class and struct interchangeably (I don't like class with struct-like layout for example, no private members, etc). If any compiler where to warn about that I would just use a flag to silent such warning.

    —
    Reply to this email directly or view it on GitHub.

  6. zygoloid commented on Aug 27, 2015

    @zygoloid
    Member

    Closing; while consistency in presentation is generally important, in this case I don't think the comprehensibility or style of the standard is affected.

  7. oblitum commented on Aug 27, 2015

    @oblitum

    I've captured the original intent of the issue re-reading it now... Well in that case it seems understandable, but it's bogus nonetheless. Personally I use class and struct interchangeably with a purpose as I said. In this case deviation from the original template in the specialization doesn't look purposeful but there's no rule one can really form about that. Such warnings woudn't apply for me for example, since any specialization may happen to be more class-like or struct-like, and I use the proper keyword in each case, regardless of the keyword used for the original template.

  8. Arcoth commented on Aug 28, 2015

    @Arcoth
    ContributorAuthor

    @zygoloid It might be sensible to uncouple-Wmismatched-tags from -Wall then, for Clang. (You can do that, right?)

    Edit: Hmm, a bit of research reveals that this is partially relevant for linking, as the VS ABI appears to link struct and class differently. Still seems that having to activate it explicitly is more sensible, though.

  9. jwakely commented on Aug 28, 2015

    @jwakely
    Member

    @Arcoth, I still don't understand why you think the use of struct or class here in the standard has anything to do with warnings from your compiler. How we present this information in the standard does not dictate how vendors implement those specializations. If you get warnings complain to your std::lib vendor, but this is not the right venue.

  10. Arcoth commented on Aug 28, 2015

    @Arcoth
    ContributorAuthor

    I still don't understand why you think the use of struct or class here in the standard has anything to do with warnings from your compiler.

    I don't (anymore).

    If you get warnings complain to your std::lib vendor, but this is not the right venue.

    I was talking about Clang's nonsensical warning that annoyed me, which was the original incentive for opening this issue. I asked a Clang dev above whether removing it from -Wall is sensible - but apparently OT isn't welcome here. I'll ask somewhere else then.

  11. sigfpe commented on Aug 28, 2015

    @sigfpe

    You do realize this is not the place to ask your vendor to do something very specific to your compiler. 

    -------- Original message --------
    From: Arcoth notifications@github.com
    Date: 08/28/2015 2:26 AM (GMT-08:00)
    To: cplusplus/draft draft@noreply.github.com
    Cc: sigfpe sig.fpe@axiomatics.org
    Subject: Re: [draft] Inconsistent class-key in class template declarations
    (#534)

    I still don't understand why you think the use of struct or class here in the standard has anything to do with warnings from your compiler.

    I don't.

    If you get warnings complain to your std::lib vendor, but this is not the right venue.

    I was talking about Clang's nonsensical warning that annoyed me, which was the original incentive for opening this issue. I asked a Clang dev above - apparently you're not welcoming OT. I'll ask somewhere else then.

    —
    Reply to this email directly or view it on GitHub.

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

      Issue actions