public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "fasdfasdas at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/60878] New: Explicit Specialization of Inner Template Class In A Template Class, Using an Enum in Parent Template Class as Template Argument
Date: Thu, 17 Apr 2014 22:17:00 -0000	[thread overview]
Message-ID: <bug-60878-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 60878
           Summary: Explicit Specialization of Inner Template Class In A
                    Template Class, Using an Enum in Parent Template Class
                    as Template Argument
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fasdfasdas at gmail dot com

The following code compiles in clang++ 3.5 (as of yesterday's unstable branch)
and g++ 4.6.3. It does not compile with clang++ 2.9. It also compiles on "GNU
C++ (GCC) version 4.8.2 20140206 (prerelease) (x86_64-unknown-linux-gnu)" but
not "GNU C++ (Arch Repository) version 4.8.2 (arm-none-eabi)".

The compilers that do not compile the code gives an error saying:

test.cpp: In function 'int main()':
test.cpp:60:7: error: 'class Port<0u>::Pin<5u, (Port<0u>::PinMode)1>' has no
member named 'set'
   pin.set();
       ^

Apparently, they do choose the class template, not the specialization.

Code to reproduce:

#include <cstdint>

template<std::size_t port>
class Port
{
public: //Declarations
  enum class PinMode
  {
    Input = 0x0,
    Output = 0x1,
    Alternate = 0x2,
    Analog = 0x3
  };

  template<uint8_t nPin, PinMode mode>
  class Pin
  {

  };

  template<uint8_t nPin>
  class Pin<nPin, PinMode::Output>
  {
  public: //Declarations
    enum class OutputSpeed : uint32_t
    {
      Low,
      Medium,
      Fast,
      High
    };

    enum class PullMode : uint32_t
    {
      None = 0x0,
      PullUp = 0x1,
      PullDown = 0x2
    };

  public: //Methods
    void setOutputSpeed(OutputSpeed const ospeed) volatile;
    void setPullMode(PullMode const ppm) volatile;

    void set() volatile
    {
      reinterpret_cast<Port<port> volatile*>(port)->m_BSRR |=
static_cast<uint16_t>(0x1) <<nPin;
    }
    void reset() volatile;

    bool getOutputState() volatile;
  }; //END OutputPin

public: //Registers
  uint32_t m_BSRR;
}; //END Port

int main()
{
  auto pin = Port<0>::Pin<5, Port<0>::PinMode::Output>();
  pin.set();
}


             reply	other threads:[~2014-04-17 22:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-17 22:17 fasdfasdas at gmail dot com [this message]
2014-04-17 22:17 ` [Bug c++/60878] " fasdfasdas at gmail dot com
2014-04-17 22:31 ` [Bug c++/60878] Explicit Specialization of Inner Template Class In A Template Class, Using an Enum class " pinskia at gcc dot gnu.org
2014-04-18  0:10 ` redi at gcc dot gnu.org
2014-06-06  9:30 ` paolo.carlini at oracle dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-60878-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).