public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/54055] New: spurious(?) "invalid use of incomplete type" warning in template definition
@ 2012-07-20 18:38 roland at gnu dot org
  2012-07-20 19:18 ` [Bug c++/54055] " daniel.kruegler at googlemail dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: roland at gnu dot org @ 2012-07-20 18:38 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 54055
           Summary: spurious(?) "invalid use of incomplete type" warning
                    in template definition
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: roland@gnu.org


Created attachment 27847
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=27847
test case, C++ source

The attached input file is culled from Chromium sources.  Past versions of
GCC do not complain about this and nor does Clang.  Trunk G++ started
giving a warning fairly recently (sometime after I left for Prague).
It happens with no special options, and also with -std=gnu++98; I didn't
test other modes.

foo.cc:3:35: warning: invalid use of incomplete type ‘class scoped_ptr<C>’
[enabled by default]
   private: struct RValue : public scoped_ptr { RValue(); ~RValue();
RValue(cons
                                   ^
foo.cc:2:7: warning: declaration of ‘class scoped_ptr<C>’ [enabled by default]
 class scoped_ptr {
       ^

This code pattern comes from using the macro MOVE_ONLY_TYPE_FOR_CPP_03
as defined here:
    http://src.chromium.org/viewvc/chrome/trunk/src/base/move.h?view=markup

Is this code really invalid C++?  If so, was it intended to start rejecting
it without any new -std= or -Wfoo options when G++ never did before?


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

* [Bug c++/54055] spurious(?) "invalid use of incomplete type" warning in template definition
  2012-07-20 18:38 [Bug c++/54055] New: spurious(?) "invalid use of incomplete type" warning in template definition roland at gnu dot org
@ 2012-07-20 19:18 ` daniel.kruegler at googlemail dot com
  2012-07-20 19:26 ` redi at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2012-07-20 19:18 UTC (permalink / raw)
  To: gcc-bugs

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

Daniel Krügler <daniel.kruegler at googlemail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |daniel.kruegler at
                   |                            |googlemail dot com

--- Comment #1 from Daniel Krügler <daniel.kruegler at googlemail dot com> 2012-07-20 19:18:03 UTC ---
Your example can be reduced to the following model code:

template<typename T>
struct A
{
  struct B : A { };
};

I can assure you that you cannot rely on that. This example has recently been
raised to the committee and it was not 100% clear what the result should be. A
new core language issue will be opened for this. The problem is that some
arguments were brought pointing to the equivalent example

struct A
{
  struct B : A { };
};

being invalid since ages. There is no tendency to make the latter valid, but is
has to be clarified what the state of the first (your) example will be.


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

* [Bug c++/54055] spurious(?) "invalid use of incomplete type" warning in template definition
  2012-07-20 18:38 [Bug c++/54055] New: spurious(?) "invalid use of incomplete type" warning in template definition roland at gnu dot org
  2012-07-20 19:18 ` [Bug c++/54055] " daniel.kruegler at googlemail dot com
@ 2012-07-20 19:26 ` redi at gcc dot gnu.org
  2012-07-21 14:11 ` jason at gcc dot gnu.org
  2012-07-22 11:27 ` paolo.carlini at oracle dot com
  3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2012-07-20 19:26 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-07-20 19:26:28 UTC ---
The code is IMHO invalid, and apparently EDG compilers reject it. 
[class.derived] says "The type denoted by a base-type-specifier shall be a
class type that is not an incompletely defined class (Clause 9)" and scoped_ptr
is not complete until the end of its definition.

Jason asked about exactly this situation on the c++ core reflector 3 days ago,
so I assume he changed it intentionally, or at least is aware of it.

You can make the code portable (whatever the resolution of the core issue) by
moving the definition of scoped_ptr::Rvalue to a point where scoped_ptr is
complete:

template<class C>
struct scoped_ptr {
  struct RValue;  // declare
};

// define
template<class C>
struct scoped_ptr<C>::Rvalue : scoped_ptr<C> {
};


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

* [Bug c++/54055] spurious(?) "invalid use of incomplete type" warning in template definition
  2012-07-20 18:38 [Bug c++/54055] New: spurious(?) "invalid use of incomplete type" warning in template definition roland at gnu dot org
  2012-07-20 19:18 ` [Bug c++/54055] " daniel.kruegler at googlemail dot com
  2012-07-20 19:26 ` redi at gcc dot gnu.org
@ 2012-07-21 14:11 ` jason at gcc dot gnu.org
  2012-07-22 11:27 ` paolo.carlini at oracle dot com
  3 siblings, 0 replies; 5+ messages in thread
From: jason at gcc dot gnu.org @ 2012-07-21 14:11 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Jason Merrill <jason at gcc dot gnu.org> 2012-07-21 14:11:11 UTC ---
Yes, it was intentional, based on the discussion mentioned in the other
comments.  I made it a pedwarn rather than a hard error so that affected code
would continue to compile.


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

* [Bug c++/54055] spurious(?) "invalid use of incomplete type" warning in template definition
  2012-07-20 18:38 [Bug c++/54055] New: spurious(?) "invalid use of incomplete type" warning in template definition roland at gnu dot org
                   ` (2 preceding siblings ...)
  2012-07-21 14:11 ` jason at gcc dot gnu.org
@ 2012-07-22 11:27 ` paolo.carlini at oracle dot com
  3 siblings, 0 replies; 5+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-07-22 11:27 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #4 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-07-22 11:27:20 UTC ---
Let's close this then.


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

end of thread, other threads:[~2012-07-22 11:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-20 18:38 [Bug c++/54055] New: spurious(?) "invalid use of incomplete type" warning in template definition roland at gnu dot org
2012-07-20 19:18 ` [Bug c++/54055] " daniel.kruegler at googlemail dot com
2012-07-20 19:26 ` redi at gcc dot gnu.org
2012-07-21 14:11 ` jason at gcc dot gnu.org
2012-07-22 11:27 ` paolo.carlini at oracle dot com

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