public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/65157] New: Unable to define a static template member function of a nested class as a friend of a sibling class.
@ 2015-02-21 21:02 brian.a.curtis at gmail dot com
  2021-12-13 15:43 ` [Bug c++/65157] " pinskia at gcc dot gnu.org
  2021-12-13 15:44 ` pinskia at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: brian.a.curtis at gmail dot com @ 2015-02-21 21:02 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="UTF-8", Size: 7342 bytes --]

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65157

            Bug ID: 65157
           Summary: Unable to define a static template member function of
                    a nested class as a friend of a sibling class.
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: brian.a.curtis at gmail dot com

Created attachment 34824
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34824&action=edit
preprocessed file

SUMMARY:

Unable to define a static template member function of a nested class
as a friend of a sibling class.



EXAMPLE:

template <typename T> class A {
 public:
  class B;
  template <typename U> class C;
};

template <typename T>
class A<T>::B {
 public:
  template <typename U> static void Create();
};

template <typename T> template <typename U>
class A<T>::C {
 C() = default;
 friend void B::Create<U>();
};

template <typename T> template <typename U>
void A<T>::B::Create() {
  C<U>{};
}

int main() {
  A<int>::B::Create<char>();
}



COMPILATION COMMAND:

gcc -std=c++ -Wall -Wextra -fno-strict-aliasing -fwrapv
-fno-aggressive-loop-optimizations test.cpp -o test



DATA COLLECTION COMMAND:

gcc -v -save-temps -std=c++11 -Wall -Wextra -fno-strict-aliasing
-fwrapv -fno-aggressive-loop-optimizations test.cpp



OUTPUT:

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
4.8.2-19ubuntu1'
--with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs
--enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.8 --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext
--enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.8
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--enable-gnu-unique-object --disable-libmudflap --enable-plugin
--with-system-zlib --disable-browser-plugin --enable-java-awt=gtk
--enable-gtk-cairo
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre
--enable-java-home
--with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64
--with-arch-directory=amd64
--with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc
--enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --with-tune=generic
--enable-checking=release --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1)
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=c++11' '-Wall' '-Wextra'
'-fno-strict-aliasing' '-fwrapv' '-fno-aggressive-loop-optimizations'
'-mtune=generic' '-march=x86-64'
 /usr/lib/gcc/x86_64-linux-gnu/4.8/cc1plus -E -quiet -v -imultiarch
x86_64-linux-gnu -D_GNU_SOURCE test.cpp -mtune=generic -march=x86-64
-std=c++11 -Wall -Wextra -fno-strict-aliasing -fwrapv
-fno-aggressive-loop-optimizations -fpch-preprocess -fstack-protector
-Wformat -Wformat-security -o test.ii
ignoring duplicate directory "/usr/include/x86_64-linux-gnu/c++/4.8"
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../x86_64-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/c++/4.8
 /usr/include/x86_64-linux-gnu/c++/4.8
 /usr/include/c++/4.8/backward
 /usr/lib/gcc/x86_64-linux-gnu/4.8/include
 /usr/local/include
 /usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=c++11' '-Wall' '-Wextra'
'-fno-strict-aliasing' '-fwrapv' '-fno-aggressive-loop-optimizations'
'-mtune=generic' '-march=x86-64'
 /usr/lib/gcc/x86_64-linux-gnu/4.8/cc1plus -fpreprocessed test.ii
-quiet -dumpbase test.cpp -mtune=generic -march=x86-64 -auxbase test
-Wall -Wextra -std=c++11 -version -fno-strict-aliasing -fwrapv
-fno-aggressive-loop-optimizations -fstack-protector -Wformat
-Wformat-security -o test.s
GNU C++ (Ubuntu 4.8.2-19ubuntu1) version 4.8.2 (x86_64-linux-gnu)
compiled by GNU C version 4.8.2, GMP version 5.1.3, MPFR version
3.1.2-p3, MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU C++ (Ubuntu 4.8.2-19ubuntu1) version 4.8.2 (x86_64-linux-gnu)
compiled by GNU C version 4.8.2, GMP version 5.1.3, MPFR version
3.1.2-p3, MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 26a7c0bd346d04102f6aea776e0cccc5
test.cpp: In instantiation of ‘class A<int>::C<char>’:
test.cpp:21:3:   required from ‘static void A<T>::B::Create() [with U
= char; T = int]’
test.cpp:25:27:   required from here
test.cpp:16:14: error: ‘Create’ was not declared in this scope
  friend void B::Create<U>();
              ^
>From gcc-bugs-return-478066-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sat Feb 21 20:48:40 2015
Return-Path: <gcc-bugs-return-478066-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 10249 invoked by alias); 21 Feb 2015 20:48:40 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 10202 invoked by uid 48); 21 Feb 2015 20:48:35 -0000
From: "olegendo at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/65151] [SH][4.9 Regression] Internal compiler error when trying to build libav 11.2 on sh4
Date: Sat, 21 Feb 2015 21:05:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: target
X-Bugzilla-Version: 4.9.2
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: olegendo at gcc dot gnu.org
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: attachments.created
Message-ID: <bug-65151-4-fgWkdqM3g9@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-65151-4@http.gcc.gnu.org/bugzilla/>
References: <bug-65151-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2015-02/txt/msg02398.txt.bz2
Content-length: 233

https://gcc.gnu.org/bugzilla/show_bug.cgi?ide151

--- Comment #4 from Oleg Endo <olegendo at gcc dot gnu.org> ---
Created attachment 34825
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id4825&actioníit
a reduced test case


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

* [Bug c++/65157] Unable to define a static template member function of a nested class as a friend of a sibling class.
  2015-02-21 21:02 [Bug c++/65157] New: Unable to define a static template member function of a nested class as a friend of a sibling class brian.a.curtis at gmail dot com
@ 2021-12-13 15:43 ` pinskia at gcc dot gnu.org
  2021-12-13 15:44 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-13 15:43 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65157

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2021-12-13
             Status|UNCONFIRMED                 |NEW

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed, the following should compile too but does not:
template <typename T>
class A {
 public:
  class C;
  template <typename U> static void d();
};

template <typename T>
class A<T>::C {
 C();
 friend void A<T>::d<char>();
};

template <typename T> template <typename U>
void A<T>::d() {
  C a{};
}

int main() {
  A<char>::d<char>();
}
---- CUT ---
the original testcase which had "C() = default;" is able to compile in GCC 9+
but the friend is not really recognized.

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

* [Bug c++/65157] Unable to define a static template member function of a nested class as a friend of a sibling class.
  2015-02-21 21:02 [Bug c++/65157] New: Unable to define a static template member function of a nested class as a friend of a sibling class brian.a.curtis at gmail dot com
  2021-12-13 15:43 ` [Bug c++/65157] " pinskia at gcc dot gnu.org
@ 2021-12-13 15:44 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-13 15:44 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65157

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #3)


Note if I change d not to be a template, then GCC is able to recognize the
friend and the code compiles.

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

end of thread, other threads:[~2021-12-13 15:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-21 21:02 [Bug c++/65157] New: Unable to define a static template member function of a nested class as a friend of a sibling class brian.a.curtis at gmail dot com
2021-12-13 15:43 ` [Bug c++/65157] " pinskia at gcc dot gnu.org
2021-12-13 15:44 ` pinskia at gcc dot gnu.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).