public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/47475] New: Static member function template of class variadic template can't be called from the inside
@ 2011-01-26 15:14 flo.goujeon at orange dot fr
  2011-01-26 16:48 ` [Bug c++/47475] [C++0x] " redi at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: flo.goujeon at orange dot fr @ 2011-01-26 15:14 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: Static member function template of class variadic
                    template can't be called from the inside
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: flo.goujeon@orange.fr


GCC 4.5 and 4.6 can't compile the following piece of code, which seems valid:
****************************************
template<typename... Ts>
struct test;

template<>
struct test<>
{
    template<typename>
    static void f()
    {
    }
};

template<typename T, typename... Ts>
struct test<T, Ts...>
{
    template<typename U>
    static void f()
    {
        test<Ts...>::f<U>(); //compiler error here
    }
};
****************************************

Here is the compiler error message:
****************************************
|| /usr/local/bin/g++ -c main.cpp -W -Wall -pedantic -std=c++0x
|| main.cpp: In static member function ‘static void test<T, Ts ...>::f()’:
main.cpp|19 col 19| error: expected primary-expression before ‘>’ token
main.cpp|19 col 21| error: expected primary-expression before ‘)’ token
|| make: *** [main.o] Error 1
****************************************

However, GCC doesn't complain with this:
****************************************
int main()
{
    test<int, double>::f<int>();
}
****************************************


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

* [Bug c++/47475] [C++0x] Static member function template of class variadic template can't be called from the inside
  2011-01-26 15:14 [Bug c++/47475] New: Static member function template of class variadic template can't be called from the inside flo.goujeon at orange dot fr
@ 2011-01-26 16:48 ` redi at gcc dot gnu.org
  2011-01-26 17:17 ` redi at gcc dot gnu.org
  2011-01-26 17:28 ` flo.goujeon at orange dot fr
  2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2011-01-26 16:48 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-01-26 16:41:26 UTC ---
The diagnostic isn't very good, but the code is invalid, it should be:

        test<Ts...>::template f<U>();


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

* [Bug c++/47475] [C++0x] Static member function template of class variadic template can't be called from the inside
  2011-01-26 15:14 [Bug c++/47475] New: Static member function template of class variadic template can't be called from the inside flo.goujeon at orange dot fr
  2011-01-26 16:48 ` [Bug c++/47475] [C++0x] " redi at gcc dot gnu.org
@ 2011-01-26 17:17 ` redi at gcc dot gnu.org
  2011-01-26 17:28 ` flo.goujeon at orange dot fr
  2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2011-01-26 17:17 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-01-26 16:47:53 UTC ---
Note that this is not related to variadic templates, this gives the same error
using no C++0x features:

template<typename T, typename Ts>
struct test;

template<>
struct test<void, void>
{
    template<typename>
    static void f()
    {
    }
};

template<typename T, typename Ts>
struct test
{
    template<typename U>
    static void f()
    {
        test<void, Ts>::f<U>(); //compiler error here
    }
};


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

* [Bug c++/47475] [C++0x] Static member function template of class variadic template can't be called from the inside
  2011-01-26 15:14 [Bug c++/47475] New: Static member function template of class variadic template can't be called from the inside flo.goujeon at orange dot fr
  2011-01-26 16:48 ` [Bug c++/47475] [C++0x] " redi at gcc dot gnu.org
  2011-01-26 17:17 ` redi at gcc dot gnu.org
@ 2011-01-26 17:28 ` flo.goujeon at orange dot fr
  2 siblings, 0 replies; 4+ messages in thread
From: flo.goujeon at orange dot fr @ 2011-01-26 17:28 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from flo.goujeon at orange dot fr 2011-01-26 16:54:18 UTC ---
Oh, so that is the purpose of the 'template' keyword in nested-name-specifier.
That's tricky.
Thank you Jonathan, and sorry about this invalid report.


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

end of thread, other threads:[~2011-01-26 16:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-26 15:14 [Bug c++/47475] New: Static member function template of class variadic template can't be called from the inside flo.goujeon at orange dot fr
2011-01-26 16:48 ` [Bug c++/47475] [C++0x] " redi at gcc dot gnu.org
2011-01-26 17:17 ` redi at gcc dot gnu.org
2011-01-26 17:28 ` flo.goujeon at orange dot fr

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