public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/40901]  New: Access qualifiers of embedded templates are discarded
@ 2009-07-29  9:45 jakobsybren at gmail dot com
  2009-07-29 11:01 ` [Bug c++/40901] " jwakely dot gcc at gmail dot com
  2009-08-25 14:04 ` bangerth at gmail dot com
  0 siblings, 2 replies; 5+ messages in thread
From: jakobsybren at gmail dot com @ 2009-07-29  9:45 UTC (permalink / raw)
  To: gcc-bugs

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


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

* [Bug c++/40901] Access qualifiers of embedded templates are discarded
  2009-07-29  9:45 [Bug c++/40901] New: Access qualifiers of embedded templates are discarded jakobsybren at gmail dot com
@ 2009-07-29 11:01 ` jwakely dot gcc at gmail dot com
  2009-08-25 14:04 ` bangerth at gmail dot com
  1 sibling, 0 replies; 5+ messages in thread
From: jwakely dot gcc at gmail dot com @ 2009-07-29 11:01 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from jwakely dot gcc at gmail dot com  2009-07-29 11:01 -------
looks similar to bug 40843 but I'm not sure if it's the same


-- 


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


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

* [Bug c++/40901] Access qualifiers of embedded templates are discarded
  2009-07-29  9:45 [Bug c++/40901] New: Access qualifiers of embedded templates are discarded jakobsybren at gmail dot com
  2009-07-29 11:01 ` [Bug c++/40901] " jwakely dot gcc at gmail dot com
@ 2009-08-25 14:04 ` bangerth at gmail dot com
  1 sibling, 0 replies; 5+ messages in thread
From: bangerth at gmail dot com @ 2009-08-25 14:04 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from bangerth at gmail dot com  2009-08-25 14:04 -------
Confirmed:
---------------------------------
class A {
  template <int> struct s {
    enum { value };
  };
};

int i = A::s<10>::value;
---------------------------------
This should produce an error but doesn't.

W.


-- 

bangerth at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bangerth at gmail dot com
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2009-08-25 14:04:38
               date|                            |


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


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

* [Bug c++/40901] Access qualifiers of embedded templates are discarded
       [not found] <bug-40901-4@http.gcc.gnu.org/bugzilla/>
  2011-01-18 15:19 ` redi at gcc dot gnu.org
@ 2011-01-18 15:20 ` redi at gcc dot gnu.org
  1 sibling, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2011-01-18 15:20 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-01-18 15:11:05 UTC ---
(In reply to comment #3)
> access control isn't done for a nested-name-specifier

sorry, should be  "... for arguments in a template-id in a
nested-name-specifier"


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

* [Bug c++/40901] Access qualifiers of embedded templates are discarded
       [not found] <bug-40901-4@http.gcc.gnu.org/bugzilla/>
@ 2011-01-18 15:19 ` redi at gcc dot gnu.org
  2011-01-18 15:20 ` redi at gcc dot gnu.org
  1 sibling, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2011-01-18 15:19 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-01-18 15:07:56 UTC ---
access control isn't done for a nested-name-specifier

class C
{
  struct Private { };
};

template<typename T>
struct exploit
{
    typedef T type;
};

exploit<C::Private>::type x2;   // should be an error


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

end of thread, other threads:[~2011-01-18 15:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-29  9:45 [Bug c++/40901] New: Access qualifiers of embedded templates are discarded jakobsybren at gmail dot com
2009-07-29 11:01 ` [Bug c++/40901] " jwakely dot gcc at gmail dot com
2009-08-25 14:04 ` bangerth at gmail dot com
     [not found] <bug-40901-4@http.gcc.gnu.org/bugzilla/>
2011-01-18 15:19 ` redi at gcc dot gnu.org
2011-01-18 15:20 ` redi 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).