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

Inconsistent class-key in class template declarations #534

Closed
Arcoth opened this issue Aug 27, 2015 · 11 comments
Closed

Inconsistent class-key in class template declarations #534

Arcoth opened this issue Aug 27, 2015 · 11 comments

Comments

@Arcoth
Copy link
Contributor

Arcoth commented Aug 27, 2015

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.

@jwakely
Copy link
Member

jwakely commented Aug 27, 2015

Compilers don't compile declarations in the standard.

@Arcoth
Copy link
Contributor Author

Arcoth commented Aug 27, 2015

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!)

@jwakely
Copy link
Member

jwakely commented Aug 27, 2015

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.

@oblitum
Copy link

oblitum commented Aug 27, 2015

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.

@sigfpe
Copy link

sigfpe commented Aug 27, 2015

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.

@zygoloid
Copy link
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.

@oblitum
Copy link

oblitum commented Aug 27, 2015

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.

@Arcoth
Copy link
Contributor Author

Arcoth commented Aug 28, 2015

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

@jwakely
Copy link
Member

jwakely commented Aug 28, 2015

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

@Arcoth
Copy link
Contributor Author

Arcoth commented Aug 28, 2015

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.

@sigfpe
Copy link

sigfpe commented Aug 28, 2015

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants