public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/41972]  New: static reference as a template parameter fails
@ 2009-11-06 16:37 navinkumar+bugs at gmail dot com
  2009-11-06 16:39 ` [Bug c++/41972] " navinkumar+bugs at gmail dot com
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: navinkumar+bugs at gmail dot com @ 2009-11-06 16:37 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1198 bytes --]

in certain cases, GCC is unable to pass a static reference as a template
parameter.

SCENARIO 1 (SUCCEEDS):
//test1.cpp
template <typename T>
class X {
public:
 static const T x;
};

template <typename T>
class Y {
public:
 typedef X<T> wrapper_t;
 template <const double& _test_>
 class Foo { };
public:
 typedef Foo<wrapper_t::x> type;
};

SCENARIO 2 (FAILS):
// test2.cpp
template <typename T>
class X {
public:
    static const T x;
};

template <typename _ignore_>
class Y {
public:
    typedef X<double> wrapper_t;
    template <const double& _test_>
    class Foo { };
public:
    typedef Foo<wrapper_t::x> type;
};

template class Y<void>;

COMPILER ERROR FOR SCENARIO 2:
test2.cpp:14: error: ‘X<double>::x’ cannot appear in a constant-expression
test2.cpp:14: error: template argument 1 is invalid


-- 
           Summary: static reference as a template parameter fails
           Product: gcc
           Version: 4.4.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: navinkumar+bugs at gmail dot com


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


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

end of thread, other threads:[~2009-11-09 22:02 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-06 16:37 [Bug c++/41972] New: static reference as a template parameter fails navinkumar+bugs at gmail dot com
2009-11-06 16:39 ` [Bug c++/41972] " navinkumar+bugs at gmail dot com
2009-11-06 16:40 ` navinkumar+bugs at gmail dot com
2009-11-06 17:22 ` [Bug c++/41972] [4.3/4.4/4.5 Regression] nondependent static member function as a reference " pinskia at gcc dot gnu dot org
2009-11-09 15:28 ` jason at gcc dot gnu dot org
2009-11-09 18:33 ` jason at gcc dot gnu dot org
2009-11-09 20:28 ` jason at gcc dot gnu dot org
2009-11-09 22:01 ` jason at gcc dot gnu dot org
2009-11-09 22:02 ` jason at gcc dot gnu dot 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).