public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/20234] New: incorrect error: class has not been declared
@ 2005-02-27 21:05 fang at csl dot cornell dot edu
  2005-02-28 22:01 ` [Bug c++/20234] " bangerth at dealii dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: fang at csl dot cornell dot edu @ 2005-02-27 21:05 UTC (permalink / raw)
  To: gcc-bugs

g++-4.0s give the following incorrect error on valid code (it should be accepted, I think):
gcc4rejectvalid.cc:25: error: 'persistent_object_manager' has not been declared


Run command
g++-4.0 -v --save-temps -c gcc4rejectvalid.cc -o gcc4rejectvalid.o


Output with version specs:
Using built-in specs.
Configured with: ../configure --prefix=/sw --prefix=/sw/lib/gcc4 --enable-
languages=c,c++,objc,f95,java --infodir=/share/info --with-gmp=/sw --with-as=/sw/lib/odcctools/
bin/as --with-ld=/sw/lib/odcctools/bin/ld --with-included-gettext --host=powerpc-apple-darwin
Thread model: posix
gcc version 4.0.0 20050130 (experimental)
 /sw/lib/gcc4/libexec/gcc/powerpc-apple-darwin/4.0.0/cc1plus -E -quiet -v -D__DYNAMIC__ 
-D__APPLE_CC__=1 gcc4rejectvalid.cc -fPIC -fpch-preprocess -o gcc4rejectvalid.ii
ignoring nonexistent directory "/sw/lib/gcc4/lib/gcc/powerpc-apple-darwin/4.0.0/../../../../powerpc-
apple-darwin/include"
#include "..." search starts here:
#include <...> search starts here:
 /sw/lib/gcc4/lib/gcc/powerpc-apple-darwin/4.0.0/../../../../include/c++/4.0.0
 /sw/lib/gcc4/lib/gcc/powerpc-apple-darwin/4.0.0/../../../../include/c++/4.0.0/powerpc-apple-
darwin
 /sw/lib/gcc4/lib/gcc/powerpc-apple-darwin/4.0.0/../../../../include/c++/4.0.0/backward
 /usr/local/include
 /sw/lib/gcc4/include
 /sw/lib/gcc4/lib/gcc/powerpc-apple-darwin/4.0.0/include
 /usr/include
 /System/Library/Frameworks
 /Library/Frameworks
End of search list.
 /sw/lib/gcc4/libexec/gcc/powerpc-apple-darwin/4.0.0/cc1plus -fpreprocessed gcc4rejectvalid.ii 
-fPIC -quiet -dumpbase gcc4rejectvalid.cc -auxbase-strip gcc4rejectvalid.o -version -o 
gcc4rejectvalid.s
GNU C++ version 4.0.0 20050130 (experimental) (powerpc-apple-darwin)
        compiled by GNU C version 3.3 20030304 (Apple Computer, Inc. build 1640).
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
gcc4rejectvalid.cc:25: error: 'persistent_object_manager' has not been declared

------------- gcc4rejectvalid.ii ---------------
# 1 "gcc4rejectvalid.cc"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "gcc4rejectvalid.cc"
namespace util
{
  class persistent_object_manager;
  namespace memory
  {

    class pointer_manipulator
    {
      friend class persistent_object_manager;
    };
  }
}
namespace util
{
  using namespace memory;

  class persistent_object_manager
  {
 static const int foo;
  };
}

namespace util {
 const int
 persistent_object_manager::foo = 666;
}
---------- end-of-file ------------

Remarks:
The above code is accepted by gcc-3.3 and 3.4.  
The example above was created from a variation of the code reported in PR 19948, and may be closely 
related.  

The error goes away when:
1) the first friend declaration is class pointer_manipulator is removed. 
2) add a using util::persistent_object_manager; in namespace memory before defining class 
pointer_manipulator.  

Workaround:
Use 2).  (This workaround also applies to PR 19948.)

-- 
           Summary: incorrect error: class has not been declared
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: fang at csl dot cornell dot edu
                CC: gcc-bugs at gcc dot gnu dot org


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


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

* [Bug c++/20234] incorrect error: class has not been declared
  2005-02-27 21:05 [Bug c++/20234] New: incorrect error: class has not been declared fang at csl dot cornell dot edu
@ 2005-02-28 22:01 ` bangerth at dealii dot org
  2005-02-28 22:04 ` [Bug c++/20234] ambiguity with friend name injection and using directive bangerth at dealii dot org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: bangerth at dealii dot org @ 2005-02-28 22:01 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2005-02-28 15:47 -------
Kriang is our resident expert on this. A shorter testcase is this: 
------------------- 
class C; 
 
namespace NS { 
  class A { 
      friend class C; 
  }; 
} 
using namespace NS; 
 
class C {}; 
C c; 
---------------------------- 
g/x> /home/bangerth/bin/gcc-3.4*/bin/c++ -c x.cc 
 
g/x> /home/bangerth/bin/gcc-4.0-pre/bin/c++ -c x.cc 
x.cc:11: error: ?C? does not name a type 
 
g/x> icc -Xc -ansi -c x.cc 
 
The error is really that gcc thinks that the class is ambiguous -- the 
fact that it says something completely different is a second symptom of 
really bad error messages, but this case is covered in another PR. The 
question here is: is the use of the name 'C' ambiguous or is it not. 
 
W. 

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lerdsuwa at gcc dot gnu dot
                   |                            |org


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


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

* [Bug c++/20234] ambiguity with friend name injection and using directive
  2005-02-27 21:05 [Bug c++/20234] New: incorrect error: class has not been declared fang at csl dot cornell dot edu
  2005-02-28 22:01 ` [Bug c++/20234] " bangerth at dealii dot org
@ 2005-02-28 22:04 ` bangerth at dealii dot org
  2005-03-03 16:27 ` lerdsuwa at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: bangerth at dealii dot org @ 2005-02-28 22:04 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|incorrect error: class has  |ambiguity with friend name
                   |not been declared           |injection and using
                   |                            |directive


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


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

* [Bug c++/20234] ambiguity with friend name injection and using directive
  2005-02-27 21:05 [Bug c++/20234] New: incorrect error: class has not been declared fang at csl dot cornell dot edu
  2005-02-28 22:01 ` [Bug c++/20234] " bangerth at dealii dot org
  2005-02-28 22:04 ` [Bug c++/20234] ambiguity with friend name injection and using directive bangerth at dealii dot org
@ 2005-03-03 16:27 ` lerdsuwa at gcc dot gnu dot org
  2005-03-03 16:28 ` lerdsuwa at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: lerdsuwa at gcc dot gnu dot org @ 2005-03-03 16:27 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2005-03-03 16:27:29
               date|                            |


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


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

* [Bug c++/20234] ambiguity with friend name injection and using directive
  2005-02-27 21:05 [Bug c++/20234] New: incorrect error: class has not been declared fang at csl dot cornell dot edu
                   ` (2 preceding siblings ...)
  2005-03-03 16:27 ` lerdsuwa at gcc dot gnu dot org
@ 2005-03-03 16:28 ` lerdsuwa at gcc dot gnu dot org
  2005-03-12 15:13 ` lerdsuwa at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: lerdsuwa at gcc dot gnu dot org @ 2005-03-03 16:28 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From lerdsuwa at gcc dot gnu dot org  2005-03-03 16:28 -------
I think NS::C should remain hidden so the declaration:
  C c;
should be OK.


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |lerdsuwa at gcc dot gnu dot
                   |dot org                     |org
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2005-03-03 16:27:29         |2005-03-03 16:28:43
               date|                            |


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


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

* [Bug c++/20234] ambiguity with friend name injection and using directive
  2005-02-27 21:05 [Bug c++/20234] New: incorrect error: class has not been declared fang at csl dot cornell dot edu
                   ` (3 preceding siblings ...)
  2005-03-03 16:28 ` lerdsuwa at gcc dot gnu dot org
@ 2005-03-12 15:13 ` lerdsuwa at gcc dot gnu dot org
  2005-03-14 14:40 ` lerdsuwa at gcc dot gnu dot org
  2005-03-14 15:30 ` lerdsuwa at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: lerdsuwa at gcc dot gnu dot org @ 2005-03-12 15:13 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From lerdsuwa at gcc dot gnu dot org  2005-03-12 15:13 -------
The patch that fixes this bug is the same as the one
in PR1016.  Closing it as a duplicate.

*** This bug has been marked as a duplicate of 1016 ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
  BugsThisDependsOn|                            |1016
             Status|ASSIGNED                    |RESOLVED
           Keywords|                            |patch
         Resolution|                            |DUPLICATE


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


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

* [Bug c++/20234] ambiguity with friend name injection and using directive
  2005-02-27 21:05 [Bug c++/20234] New: incorrect error: class has not been declared fang at csl dot cornell dot edu
                   ` (4 preceding siblings ...)
  2005-03-12 15:13 ` lerdsuwa at gcc dot gnu dot org
@ 2005-03-14 14:40 ` lerdsuwa at gcc dot gnu dot org
  2005-03-14 15:30 ` lerdsuwa at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: lerdsuwa at gcc dot gnu dot org @ 2005-03-14 14:40 UTC (permalink / raw)
  To: gcc-bugs



-- 
Bug 20234 depends on bug 1016, which changed state.

Bug 1016 Summary: [DR 166] friend class declarations not observing namespace rules.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=1016

           What    |Old Value                   |New Value
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED

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


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

* [Bug c++/20234] ambiguity with friend name injection and using directive
  2005-02-27 21:05 [Bug c++/20234] New: incorrect error: class has not been declared fang at csl dot cornell dot edu
                   ` (5 preceding siblings ...)
  2005-03-14 14:40 ` lerdsuwa at gcc dot gnu dot org
@ 2005-03-14 15:30 ` lerdsuwa at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: lerdsuwa at gcc dot gnu dot org @ 2005-03-14 15:30 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.1.0


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


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

end of thread, other threads:[~2005-03-14 15:30 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-02-27 21:05 [Bug c++/20234] New: incorrect error: class has not been declared fang at csl dot cornell dot edu
2005-02-28 22:01 ` [Bug c++/20234] " bangerth at dealii dot org
2005-02-28 22:04 ` [Bug c++/20234] ambiguity with friend name injection and using directive bangerth at dealii dot org
2005-03-03 16:27 ` lerdsuwa at gcc dot gnu dot org
2005-03-03 16:28 ` lerdsuwa at gcc dot gnu dot org
2005-03-12 15:13 ` lerdsuwa at gcc dot gnu dot org
2005-03-14 14:40 ` lerdsuwa at gcc dot gnu dot org
2005-03-14 15:30 ` lerdsuwa at gcc dot gnu dot 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).