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

             Bug #: 51155
           Summary: sizeof and sizeof... in template partial
                    specialization
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: pubb...@gmail.com


-std=c++11
gcc version 4.7.0 20111112 (experimental) (GCC) 

---

14.5.5.8 of n324 states:

"A partially specialized non-type argument expression shall not involve a
template parameter of the
partial specialization except when the argument expression is a simple
identiļ¬er."

From what I understand, this seems to be broken when using sizeof:

---

template <int a, int b>
struct foo { };

// partial specializations:
template <int a>
struct foo<a, 0> { };         // correct and compiles
template <int a>
struct foo<a + 1, 0> { };     // not correct and doesn't compile
template <int a>
struct foo<sizeof(a), 0> { }; // not correct and doesn't compile
                              // due to 'a' not being used
template <int a>
struct foo<sizeof(a), a> { }; // not correct and compiles

---

Additional bugs when using sizeof.. with a variadic template

---

template <int n, int... xs>
struct foo { };

// partial specialization:
template <int... xs>
struct foo<sizeof...(xs), xs...> { }; // not correct and doesn't compile
                                      // although it should if sizeof is
allowed

template <int... xs>
struct foo<sizeof(xs), xs...> { };    // not correct and compiles
                                      // sizeof(xs) evaluates to sizeof(int)
                                      // which is incorrect
---

Reply via email to