public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/20996] New: friend class declaration in namespace wrong in template class with specialisation
@ 2005-04-13 16:59 drtr at dial dot pipex dot com
  2005-04-13 17:38 ` [Bug c++/20996] " pinskia at gcc dot gnu dot org
  2005-06-23 15:47 ` pinskia at gcc dot gnu dot org
  0 siblings, 2 replies; 3+ messages in thread
From: drtr at dial dot pipex dot com @ 2005-04-13 16:59 UTC (permalink / raw)
  To: gcc-bugs

The code below won't compile. It behaves as though the line
class val<T> { friend class rec; } is erroneously declaring a 'struct rec' in 
the global namespace. (Uncomment the other use of rec to see this.) The error
message from 4.0 is:
y.cpp: In function 'int main(int, char**)':
y.cpp:29: error: 'rec' was not declared in this scope
y.cpp:29: error: expected `;' before 'r'

This shows up on 3.4.3, 3.4.4 and 4.0. 

 David

namespace ns
{
template<typename T>
class val
{
    T get(const unsigned char *data) const;
public:
    friend class rec;   // see 7.3.1.2 
    val<T>() { }
};

template<>
inline float val<float>::get(const unsigned char *data) const
{ return *reinterpret_cast<const float *>(data); }

class rec
{
public:
    const unsigned char *data;
};

}

using namespace ns;

int
main(int argc, char **argv)
{
    rec r;
//    ::rec s;

    return 0;
}

-- 
           Summary: friend class declaration in namespace wrong in template
                    class with specialisation
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: drtr at dial dot pipex dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: x86_64-unknown-linux-gnu
  GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu


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


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

* [Bug c++/20996] friend class declaration in namespace wrong in template class with specialisation
  2005-04-13 16:59 [Bug c++/20996] New: friend class declaration in namespace wrong in template class with specialisation drtr at dial dot pipex dot com
@ 2005-04-13 17:38 ` pinskia at gcc dot gnu dot org
  2005-06-23 15:47 ` pinskia at gcc dot gnu dot org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-04-13 17:38 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-04-13 17:38 -------
Fixed on the mainline (for 4.1.0), there might be a dup of this bug somewhere with the rest of the 
friend bugs in GCC.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.1.0


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


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

* [Bug c++/20996] friend class declaration in namespace wrong in template class with specialisation
  2005-04-13 16:59 [Bug c++/20996] New: friend class declaration in namespace wrong in template class with specialisation drtr at dial dot pipex dot com
  2005-04-13 17:38 ` [Bug c++/20996] " pinskia at gcc dot gnu dot org
@ 2005-06-23 15:47 ` pinskia at gcc dot gnu dot org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-06-23 15:47 UTC (permalink / raw)
  To: gcc-bugs



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


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


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

end of thread, other threads:[~2005-06-23 15:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-13 16:59 [Bug c++/20996] New: friend class declaration in namespace wrong in template class with specialisation drtr at dial dot pipex dot com
2005-04-13 17:38 ` [Bug c++/20996] " pinskia at gcc dot gnu dot org
2005-06-23 15:47 ` pinskia 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).