[LLVMbugs] [Bug 13423] New: Incorrect "non-type template argument is not a constant expression"

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Jul 20 16:22:51 PDT 2012


http://llvm.org/bugs/show_bug.cgi?id=13423

             Bug #: 13423
           Summary: Incorrect "non-type template argument is not a
                    constant expression"
           Product: clang
           Version: trunk
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: supercilious.dude at gmail.com
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified


clang incorrectly determines "no matching function" because of a substitution
failure. The template is not resolved because "non-type template argument is
not a constant expression", which is clearly not the case. The function is
constexpr and is correctly resolved by other compilers. Clang has no problem
with it in other places like in a static_assert.

>From what I can understand of the standard, this is allowed and clang fails to
compile it in C++11 mode.

Massively simplified example follows:

#include <cstdlib>
#include <utility>

template <typename T>
class Frobnicator
{
  public:
    template <typename PolicyT>
    static constexpr bool
    can_frobnicate ( void )
    {
      return sizeof ( T ) < PolicyT::FROBNICATION_SIZE;
    }

    template <typename PolicyT>
    static typename std::enable_if<can_frobnicate<PolicyT>(), void>::type
    frobnicate ( void )
    {
    }
};

struct FrobnicationPolicy
{
  public:
    static constexpr std::size_t FROBNICATION_SIZE = 8;
};

int
main ( void )
{
  Frobnicator<char>::frobnicate<FrobnicationPolicy>();
}

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list