[Bug c++/20996] New: friend class declaration in namespace wrong in template class with specialisation

2005-04-13 Thread drtr at dial dot pipex dot com
The code below won't compile. It behaves as though the line
class val { 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
class val
{
T get(const unsigned char *data) const;
public:
friend class rec;   // see 7.3.1.2 
val() { }
};

template<>
inline float val::get(const unsigned char *data) const
{ return *reinterpret_cast(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


[Bug c++/39567] New: class member template function won't compile

2009-03-27 Thread drtr at dial dot pipex dot com
% g++ -v
Using built-in specs.
Target: i386-pc-solaris2.10
Configured with: ../gcc-4.3.3/configure --prefix=/home/robind/local
--with-gnu-as --with-as=/usr/sfw/bin/gas --without-gnu-ld
--with-ld=/usr/ccs/bin/ld
Thread model: posix
gcc version 4.3.3 (GCC)

With this source file:

template
struct wom
{
T afunc();
};

struct foo
{
template
T bfunc(wom w)
{
return w.afunc();
}
};

I get this compilation error:
bug.cc: In member function 'T foo::bfunc(wom)':
bug.cc:12: error: expected primary-expression before '>' token
bug.cc:12: error: expected primary-expression before ')' token

Renaming the function at line 10 from bfunc to afunc makes the code compile.

Thanks,

 David Robinson


-- 
   Summary: class member template function won't compile
   Product: gcc
   Version: 4.3.3
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
    ReportedBy: drtr at dial dot pipex dot com
 GCC build triplet: i386-pc-solaris2.10
  GCC host triplet: i386-pc-solaris2.10
GCC target triplet: i386-pc-solaris2.10


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