This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/65195] New: [5.0][C++14]Variable template cannot be used as a function


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

            Bug ID: 65195
           Summary: [5.0][C++14]Variable template cannot be used as a
                    function
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: lucdanton at free dot fr

Created attachment 34858
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34858&action=edit
Minimal testcase

$ g++-trunk --version
g++-trunk (GCC) 5.0.0 20150223 (experimental)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ cat main.cpp
template<typename T>
T constant {};

template<typename T>
struct foo {
    int operator()() const
    { return 3; }
};

template<typename T>
auto& f = constant<foo<T>>;

int main()
{
    // fine
    auto& ref = f<int>; ref();

    // error: f<int> cannot be used as a function
    f<int>();
}
$ g++-trunk -std=c++14 main.cpp
main.cpp: In function 'int main()':
main.cpp:19:12: error: 'f<int>' cannot be used as a function
     f<int>();


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]