public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/49174] New: numeric_limits<T> template is a struct not a class
@ 2011-05-26 14:47 frank@kingswood-consulting.co.uk
  2011-05-26 15:07 ` [Bug libstdc++/49174] " paolo.carlini at oracle dot com
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: frank@kingswood-consulting.co.uk @ 2011-05-26 14:47 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49174

           Summary: numeric_limits<T> template is a struct not a class
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: frank@kingswood-consulting.co.uk


ISO 14882:1998 defines in 18.2.1.4 the contents of <limits>
   template<class T> class numeric_limits

The libstdc++ header defines this as
   template<class T> struct numeric_limits


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libstdc++/49174] numeric_limits<T> template is a struct not a class
  2011-05-26 14:47 [Bug libstdc++/49174] New: numeric_limits<T> template is a struct not a class frank@kingswood-consulting.co.uk
@ 2011-05-26 15:07 ` paolo.carlini at oracle dot com
  2011-05-26 18:25 ` frank@kingswood-consulting.co.uk
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-05-26 15:07 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49174

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID

--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-05-26 14:47:05 UTC ---
There is absolutely no difference between a struct and a class in C++, besides
access control, and in 18.2.1.1 there is a 'public:' at the beginning.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libstdc++/49174] numeric_limits<T> template is a struct not a class
  2011-05-26 14:47 [Bug libstdc++/49174] New: numeric_limits<T> template is a struct not a class frank@kingswood-consulting.co.uk
  2011-05-26 15:07 ` [Bug libstdc++/49174] " paolo.carlini at oracle dot com
@ 2011-05-26 18:25 ` frank@kingswood-consulting.co.uk
  2011-05-26 18:59 ` paolo.carlini at oracle dot com
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: frank@kingswood-consulting.co.uk @ 2011-05-26 18:25 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49174

--- Comment #2 from frank@kingswood-consulting.co.uk 2011-05-26 18:25:03 UTC ---
I realize struct and class are interchangeable.
llvm with -Wextra finds the difference worth warning about.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libstdc++/49174] numeric_limits<T> template is a struct not a class
  2011-05-26 14:47 [Bug libstdc++/49174] New: numeric_limits<T> template is a struct not a class frank@kingswood-consulting.co.uk
  2011-05-26 15:07 ` [Bug libstdc++/49174] " paolo.carlini at oracle dot com
  2011-05-26 18:25 ` frank@kingswood-consulting.co.uk
@ 2011-05-26 18:59 ` paolo.carlini at oracle dot com
  2011-05-26 19:25 ` pinskia at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-05-26 18:59 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49174

--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-05-26 18:52:55 UTC ---
In my experience as implementer, the equivalence between struct and class often
makes for conciseness, like in this case: we know everything will be public
anyway, thus we can spare the access-specifier. In the specific case of limits
we are also consistent, we use 'struct' both for the primary and the
specializations, thus there is *really* nothing to possibly warn about.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libstdc++/49174] numeric_limits<T> template is a struct not a class
  2011-05-26 14:47 [Bug libstdc++/49174] New: numeric_limits<T> template is a struct not a class frank@kingswood-consulting.co.uk
                   ` (2 preceding siblings ...)
  2011-05-26 18:59 ` paolo.carlini at oracle dot com
@ 2011-05-26 19:25 ` pinskia at gcc dot gnu.org
  2011-05-26 19:29 ` paolo.carlini at oracle dot com
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2011-05-26 19:25 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49174

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> 2011-05-26 19:22:13 UTC ---
Note the reason why clang warns is because of some body at MS decided that
class and struct would act slightly different.  I think we should not follow MS
here and not warn about this.  I think clang should not warn about it either by
default but we have no control over that.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libstdc++/49174] numeric_limits<T> template is a struct not a class
  2011-05-26 14:47 [Bug libstdc++/49174] New: numeric_limits<T> template is a struct not a class frank@kingswood-consulting.co.uk
                   ` (3 preceding siblings ...)
  2011-05-26 19:25 ` pinskia at gcc dot gnu.org
@ 2011-05-26 19:29 ` paolo.carlini at oracle dot com
  2011-05-28  9:27 ` frank@kingswood-consulting.co.uk
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-05-26 19:29 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49174

--- Comment #5 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-05-26 19:25:04 UTC ---
Over my dead body Andrew ;)


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libstdc++/49174] numeric_limits<T> template is a struct not a class
  2011-05-26 14:47 [Bug libstdc++/49174] New: numeric_limits<T> template is a struct not a class frank@kingswood-consulting.co.uk
                   ` (4 preceding siblings ...)
  2011-05-26 19:29 ` paolo.carlini at oracle dot com
@ 2011-05-28  9:27 ` frank@kingswood-consulting.co.uk
  2011-05-28 12:07 ` redi at gcc dot gnu.org
  2011-05-28 12:16 ` redi at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: frank@kingswood-consulting.co.uk @ 2011-05-28  9:27 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49174

--- Comment #6 from Frank Kingswood <frank@kingswood-consulting.co.uk> 2011-05-28 08:41:05 UTC ---
What's so bad about following the ISO specification to the letter?


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libstdc++/49174] numeric_limits<T> template is a struct not a class
  2011-05-26 14:47 [Bug libstdc++/49174] New: numeric_limits<T> template is a struct not a class frank@kingswood-consulting.co.uk
                   ` (5 preceding siblings ...)
  2011-05-28  9:27 ` frank@kingswood-consulting.co.uk
@ 2011-05-28 12:07 ` redi at gcc dot gnu.org
  2011-05-28 12:16 ` redi at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2011-05-28 12:07 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49174

--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-05-28 12:01:49 UTC ---
(In reply to comment #6)
> What's so bad about following the ISO specification to the letter?

Because it makes absolutely no difference except to those who maintain the
code, and we've expressed our preference - why do you care?

libstdc++ is the GCC standard library, not clang's, so the fact someone else's
compiler doesn't like it is not our problem


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libstdc++/49174] numeric_limits<T> template is a struct not a class
  2011-05-26 14:47 [Bug libstdc++/49174] New: numeric_limits<T> template is a struct not a class frank@kingswood-consulting.co.uk
                   ` (6 preceding siblings ...)
  2011-05-28 12:07 ` redi at gcc dot gnu.org
@ 2011-05-28 12:16 ` redi at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2011-05-28 12:16 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49174

--- Comment #8 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-05-28 12:13:06 UTC ---
Besides which, we *are* following it to the letter, see 1.9 [intro.execution]
paragraph 1 and the accompanying footnote

5) This provision is sometimes called the “as-if” rule, because an
implementation is free to disregard any requirement of this
International Standard as long as the result is as if the requirement had been
obeyed, as far as can be determined from the
observable behavior of the program. For instance, an actual implementation need
not evaluate part of an expression if it can
deduce that its value is not used and that no side effects affecting the
observable behavior of the program are produced.


If there's an observable difference then it's a problem, otherwise it's
irrelevant.


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2011-05-28 12:13 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-26 14:47 [Bug libstdc++/49174] New: numeric_limits<T> template is a struct not a class frank@kingswood-consulting.co.uk
2011-05-26 15:07 ` [Bug libstdc++/49174] " paolo.carlini at oracle dot com
2011-05-26 18:25 ` frank@kingswood-consulting.co.uk
2011-05-26 18:59 ` paolo.carlini at oracle dot com
2011-05-26 19:25 ` pinskia at gcc dot gnu.org
2011-05-26 19:29 ` paolo.carlini at oracle dot com
2011-05-28  9:27 ` frank@kingswood-consulting.co.uk
2011-05-28 12:07 ` redi at gcc dot gnu.org
2011-05-28 12:16 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).