public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/63268] New: Ambiguous non-specialized static template scope is accepted
@ 2014-09-15  9:54 dak at gnu dot org
  2014-09-15 10:21 ` [Bug c++/63268] " redi at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: dak at gnu dot org @ 2014-09-15  9:54 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63268

            Bug ID: 63268
           Summary: Ambiguous non-specialized static template scope is
                    accepted
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dak at gnu dot org

The following code

template <class T>
class Bass {
  T elt;
public:
  static void bing () { }
};

class Deriv : Bass<int>
{
  void boing ()
  {
    Bass::bing ();
  }
};

compiles without warning.  However, Bass::bing, calling a static member
function of a templated class, is ambiguous.  It should be Bass<int>:: or
Bass<float>:: or whatever since being a static member and explicitly resolved
it is no longer tied to the class hierarchy of Deriv and thus it should not
matter that Bass<int> is a base class of Deriv.

I was hit by this when our project did a crosscompilation with an older version
of g++ (no idea about the exact version, but should be in the 4.4 range or so)
and balked at code like this that went unnoticed by g++ 4.8.  Specifying the
template argument class explicitly placated both 4.8 and whatever the older
compiler version was.

I think that the older compiler version was correct rejecting this.


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

* [Bug c++/63268] Ambiguous non-specialized static template scope is accepted
  2014-09-15  9:54 [Bug c++/63268] New: Ambiguous non-specialized static template scope is accepted dak at gnu dot org
@ 2014-09-15 10:21 ` redi at gcc dot gnu.org
  2014-09-15 12:09 ` dak at gnu dot org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2014-09-15 10:21 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63268

Jonathan Wakely <redi at gcc dot gnu.org> changed:

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

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The code is valid, in a class template the injected-class-name can be used
without a template argument list, so Bass refers to the current instantiation.

In the scope of Deriv the name "Bass" is in scope and refers to "Bass<int>".

See http://stackoverflow.com/q/25549652/981959


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

* [Bug c++/63268] Ambiguous non-specialized static template scope is accepted
  2014-09-15  9:54 [Bug c++/63268] New: Ambiguous non-specialized static template scope is accepted dak at gnu dot org
  2014-09-15 10:21 ` [Bug c++/63268] " redi at gcc dot gnu.org
@ 2014-09-15 12:09 ` dak at gnu dot org
  2014-09-15 12:28 ` redi at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: dak at gnu dot org @ 2014-09-15 12:09 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63268

David Kastrup <dak at gnu dot org> changed:

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

--- Comment #2 from David Kastrup <dak at gnu dot org> ---
class Deriv is not a class template.  Deriv is an ordinary class with one base
class being the specialized Bass<int>.

Your argument (and the references) would be valid for

template <class T> class Deriv : Bass<T> { ... }

but that's not what the report is about.  Digging through the C++11 draft
standard, I don't actually see that case covered at all (but then the draft
standard tends to give me a headache pretty fast).

I see no reason why in a non-template class definition the unspecialized
template name of a specialized base class should have any special state.

Assuming that you get further in the standard before headaches set in than I
do, could you cite the section that you derive your opinion from?


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

* [Bug c++/63268] Ambiguous non-specialized static template scope is accepted
  2014-09-15  9:54 [Bug c++/63268] New: Ambiguous non-specialized static template scope is accepted dak at gnu dot org
  2014-09-15 10:21 ` [Bug c++/63268] " redi at gcc dot gnu.org
  2014-09-15 12:09 ` dak at gnu dot org
@ 2014-09-15 12:28 ` redi at gcc dot gnu.org
  2014-09-15 12:32 ` redi at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2014-09-15 12:28 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63268

Jonathan Wakely <redi at gcc dot gnu.org> changed:

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

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to David Kastrup from comment #2)
> class Deriv is not a class template.

I didn't say it is.

>  Deriv is an ordinary class with one
> base class being the specialized Bass<int>.

And Bass is a class template. In the scope of Bass the name "Bass" refers to
the current specialization. See 14.6.1 [temp.local].

> I see no reason why in a non-template class definition the unspecialized
> template name of a specialized base class should have any special state.

Because names from base classes are visible in derived classes.

The injected-class-name (see 9 [class] p2) in Bass is visible in derived
classes, like any other name declared in Bass.

> Assuming that you get further in the standard before headaches set in than I
> do, could you cite the section that you derive your opinion from?

I already did, via the linked DRs in the stackoverflow answer, but have
repeated them again above.

I also double-checked with Clang and EDG, which agree with GCC.


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

* [Bug c++/63268] Ambiguous non-specialized static template scope is accepted
  2014-09-15  9:54 [Bug c++/63268] New: Ambiguous non-specialized static template scope is accepted dak at gnu dot org
                   ` (2 preceding siblings ...)
  2014-09-15 12:28 ` redi at gcc dot gnu.org
@ 2014-09-15 12:32 ` redi at gcc dot gnu.org
  2014-09-15 12:46 ` dak at gnu dot org
  2014-09-15 12:51 ` redi at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2014-09-15 12:32 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63268

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This is even documented as a fix in GCC 4.5, see
https://gcc.gnu.org/gcc-4.5/changes.html#cplusplus


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

* [Bug c++/63268] Ambiguous non-specialized static template scope is accepted
  2014-09-15  9:54 [Bug c++/63268] New: Ambiguous non-specialized static template scope is accepted dak at gnu dot org
                   ` (3 preceding siblings ...)
  2014-09-15 12:32 ` redi at gcc dot gnu.org
@ 2014-09-15 12:46 ` dak at gnu dot org
  2014-09-15 12:51 ` redi at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: dak at gnu dot org @ 2014-09-15 12:46 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63268

David Kastrup <dak at gnu dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|INVALID                     |FIXED

--- Comment #5 from David Kastrup <dak at gnu dot org> ---
Ok, I bow to your analysis.  What I consider irksome in both standard text as
well as DR176 and G++ issue descriptions and examples is that the writers
choose to obfuscate matters by mixing in an orthogonal class template as the
derived class that has nothing to do with the actual issue.

That sort of gratuitous complexity seriously contributes to the headache
inducing factors of C++ language descriptions.

Thanks


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

* [Bug c++/63268] Ambiguous non-specialized static template scope is accepted
  2014-09-15  9:54 [Bug c++/63268] New: Ambiguous non-specialized static template scope is accepted dak at gnu dot org
                   ` (4 preceding siblings ...)
  2014-09-15 12:46 ` dak at gnu dot org
@ 2014-09-15 12:51 ` redi at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2014-09-15 12:51 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63268

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|FIXED                       |INVALID

--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
FIXED is not appropriate here, your report was invalid, so there's nothing to
change.


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

end of thread, other threads:[~2014-09-15 12:51 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-15  9:54 [Bug c++/63268] New: Ambiguous non-specialized static template scope is accepted dak at gnu dot org
2014-09-15 10:21 ` [Bug c++/63268] " redi at gcc dot gnu.org
2014-09-15 12:09 ` dak at gnu dot org
2014-09-15 12:28 ` redi at gcc dot gnu.org
2014-09-15 12:32 ` redi at gcc dot gnu.org
2014-09-15 12:46 ` dak at gnu dot org
2014-09-15 12:51 ` 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).