Consider the following code fragment:
==== BEGIN CODE ======
#include <iostream>
using namespace std;

class A {
  private: //protected:
  template <size_t y>
  struct s {
    enum {value = y };
  };

  public:
  A() {}
};

int main() {
  A();
  cout << A::s<10>::value << endl;
  return 0;
}
==== END CODE ======
Both for private and protected access for the embedded template, this code will
compile without errors and show the number 10 when the resulting binary is ran.
This code should give compilation errors however, because the template is not
public. In more elaborate code where class A is used as the baseclass for
derived classes, the same problem arises. The template is public in all derived
classes both when defined as private and protected in class A.


-- 
           Summary: Access qualifiers of embedded templates are discarded
           Product: gcc
           Version: 4.3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jakobsybren at gmail dot com


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

Reply via email to