Bug#547076: regression: declaring and defining friend function inside the class body doesn't work in most cases
Package: g++-4.3
Version: 4.3.2-1.1
Severity: normal
Hello,
please consider the following code, which seems to be standard compilant
(ISO 14882, paragraph 11.4.5):
#v+
void fun3();
class C
{
void f1(){}
friend void fun1(C *ptr=0){}
friend void fun2(){}
friend void fun3(){}
}
;
main()
{
fun1();//err
fun1(new C);//ok
fun2();//err
fun3();//ok
}
#v-
It compiles without errors with g++-3.3, g++-3.4 and icc, but
g++-4.[1-3] and gcc-snapshot (from sid) gives the following error
messages:
#v+
test.cpp: In function ‘int main()’:
test.cpp:12: error: ‘fun1’ was not declared in this scope
test.cpp:14: error: ‘fun2’ was not declared in this scope
#v-
-- System Information:
Debian Release: 5.0.3
APT prefers stable
APT policy: (500, 'stable')
Architecture: i386 (i686)
Kernel: Linux 2.6.29.1-tuzonice (SMP w/2 CPU cores; PREEMPT)
Locale: LANG=pl_PL.UTF-8, LC_CTYPE=pl_PL.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
Versions of packages g++-4.3 depends on:
ii gcc-4.3 4.3.2-1.1 The GNU C compiler
ii gcc-4.3-base 4.3.2-1.1 The GNU Compiler Collection (base
ii libc6 2.7-18 GNU C Library: Shared libraries
ii libgmp3c2 2:4.2.2+dfsg-3 Multiprecision arithmetic library
ii libmpfr1ldbl 2.3.1.dfsg.1-2 multiple precision floating-point
ii libstdc++6-4.3-dev 4.3.2-1.1 The GNU Standard C++ Library v3 (d
g++-4.3 recommends no packages.
Versions of packages g++-4.3 suggests:
pn g++-4.3-multilib <none> (no description available)
ii gcc-4.3-doc 4.3.2.nf1-1 documentation for the GNU compiler
pn libstdc++6-4.3-dbg <none> (no description available)
-- no debconf information
Reply to: