public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/51155] New: sizeof and sizeof... in template partial specialization
@ 2011-11-16  7:31 pubby.8 at gmail dot com
  2011-11-16  9:13 ` [Bug c++/51155] Incorrect sizeof and sizeof... behavior " daniel.kruegler at googlemail dot com
  2021-06-01 14:28 ` ppalka at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: pubby.8 at gmail dot com @ 2011-11-16  7:31 UTC (permalink / raw)
  To: gcc-bugs

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: unassigned@gcc.gnu.org
        ReportedBy: pubby.8@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
identifier."

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


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

end of thread, other threads:[~2021-06-01 14:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-16  7:31 [Bug c++/51155] New: sizeof and sizeof... in template partial specialization pubby.8 at gmail dot com
2011-11-16  9:13 ` [Bug c++/51155] Incorrect sizeof and sizeof... behavior " daniel.kruegler at googlemail dot com
2021-06-01 14:28 ` ppalka at gcc dot gnu.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).