public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* REGRESSION: friend function declared in class not visible in same  class scope.
@ 2006-11-22  1:51 Bodo Thiesen
  2006-11-22  1:54 ` Andrew Pinski
  0 siblings, 1 reply; 2+ messages in thread
From: Bodo Thiesen @ 2006-11-22  1:51 UTC (permalink / raw)
  To: gcc-bugs

>> REGRESSION: friend function declared in class not visible in same class scope.

# cat s.i
class P {
        friend P A(long);
        friend P B(long c) { return A(c); };
};
# for ver in 3.3.6 3.4.6 4.1.1
> do
>         gcc-config i686-pc-linux-gnu-$ver >/dev/null 2>&1
>         source /etc/profile
>         export LANG=C
>         g++ -dumpversion
>         g++ -c s.i -o s.o && echo ";)"
> done 
3.3.6
;)
3.4.6
;)
4.1.1
s.i: In function 'P B(long int)':
s.i:3: error: 'A' was not declared in this scope
# g++ -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: /var/tmp/portage/gcc-4.1.1-r1/work/gcc-4.1.1/configure
--prefix=/usr --bindir=/usr/i686-pc-linux-gnu/gcc-bin/4.1.1
--includedir=/usr/lib/gcc/i686-pc-linux-gnu/4.1.1/include
--datadir=/usr/share/gcc-data/i686-pc-linux-gnu/4.1.1
--mandir=/usr/share/gcc-data/i686-pc-linux-gnu/4.1.1/man
--infodir=/usr/share/gcc-data/i686-pc-linux-gnu/4.1.1/info
--with-gxx-include-dir=/usr/lib/gcc/i686-pc-linux-gnu/4.1.1/include/g++-v4
--host=i686-pc-linux-gnu --build=i686-pc-linux-gnu --disable-altivec
--enable-nls --without-included-gettext --with-system-zlib
--disable-checking --disable-werror --disable-libunwind-exceptions
--disable-multilib --disable-libmudflap --disable-libssp
--disable-libgcj --enable-languages=c,c++,fortran --enable-shared
--enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu
Thread model: posix gcc version 4.1.1 (Gentoo 4.1.1-r1)

Regards, Bodo


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

* Re: REGRESSION: friend function declared in class not visible in same  class scope.
  2006-11-22  1:51 REGRESSION: friend function declared in class not visible in same class scope Bodo Thiesen
@ 2006-11-22  1:54 ` Andrew Pinski
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Pinski @ 2006-11-22  1:54 UTC (permalink / raw)
  To: Bodo Thiesen; +Cc: gcc-bugs

> 
> >> REGRESSION: friend function declared in class not visible in same class scope.
> 
> # cat s.i
> class P {
>         friend P A(long);
>         friend P B(long c) { return A(c); };
> };

This is not a bug as friends don't inject into the namespace according to the
C++ standard, you can work around the problem by using the option -ffriend-injection.

-- Pinski


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

end of thread, other threads:[~2006-11-22  1:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-11-22  1:51 REGRESSION: friend function declared in class not visible in same class scope Bodo Thiesen
2006-11-22  1:54 ` Andrew Pinski

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