public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/66475] New: Access checking in templates circumvented with 'using' (C++11)
@ 2015-06-09 16:47 zerolo at gmail dot com
  2015-06-09 16:54 ` [Bug c++/66475] " redi at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: zerolo at gmail dot com @ 2015-06-09 16:47 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66475

            Bug ID: 66475
           Summary: Access checking in templates circumvented with 'using'
                    (C++11)
           Product: gcc
           Version: 4.9.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zerolo at gmail dot com
  Target Milestone: ---

Created attachment 35731
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35731&action=edit
repo that compiles with g++-4.9.2 -std=c++11

This is a variant of the various access checking problems when using templates,
but I don't think it's a duplicate of any of the existing ones in
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59002 , as this one is only
triggered with the `using` directive in C++11 mode, but not when employing the
supposedly identical typedef.

Code that accesses a type that should be private compiles, even though it
shouldn't be able to. When either a) the using directive "using Base = Foo<T>"
is replaced by the equivalent typedef, or b) later no other type from Base is
publicized, then access is correctly prohibited and the example fails to
compile.

// g++-4.9.2 -std=c++11 t.cpp
template<class T>
struct Foo
{
  using type = T;
};

template<class T>
class Bar : public Foo<T>
{
  using Base = Foo<T>; // the combination of this and the public export of a
type from Base below, causes this example to compile even though it shouldn't
  // typedef Foo<T> Base; // when using typedef instead of using, it correctly
fails to compile
public:
  // without this public export, Base is correctly recognized as private, maybe
it erroneously make Base itself public?

  // whether written as 'typedef' or 'using' doesn't matter
  using type = typename Base::type;
};

Bar<int>::Base x; // shouldn't compile, Base is private

int main()
{
  return 0;
}


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

* [Bug c++/66475] Access checking in templates circumvented with 'using' (C++11)
  2015-06-09 16:47 [Bug c++/66475] New: Access checking in templates circumvented with 'using' (C++11) zerolo at gmail dot com
@ 2015-06-09 16:54 ` redi at gcc dot gnu.org
  2020-03-12 15:56 ` redi at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2015-06-09 16:54 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66475

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-06-09
             Blocks|                            |59002
     Ever confirmed|0                           |1


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59002
[Bug 59002] [meta-bug] Access checking in templates


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

* [Bug c++/66475] Access checking in templates circumvented with 'using' (C++11)
  2015-06-09 16:47 [Bug c++/66475] New: Access checking in templates circumvented with 'using' (C++11) zerolo at gmail dot com
  2015-06-09 16:54 ` [Bug c++/66475] " redi at gcc dot gnu.org
@ 2020-03-12 15:56 ` redi at gcc dot gnu.org
  2021-07-27  8:46 ` pinskia at gcc dot gnu.org
  2021-08-05  7:39 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2020-03-12 15:56 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66475

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |7.0
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Fixed by r243624:

    re PR c++/69481 (ICE with C++11 alias using with templates)

            cp/
            PR c++/69481
            * cp-tree.h (TYPE_TEMPLATE_INFO): Remove alias type checking.
            (TYPE_ALIAS_TEMPLATE_INFO): New.
            (TYPE_TEMPLATE_INFO_MAYBE_ALIAS): New.  Use those macros.
            * error.c (dump_alias_template_specialization): Adjust.
            * pt.c (maybe_process_partial_specialization)
            iterative_has_template_arg, find_parameter_packs_r,
            alias_template_specialization_p, dependent_alias_template_spec_p,
            get_underlying_template, lookup_template_class_1, unify): Adjust
            template using decl access.

            testsuite/
            PR c++/69481
            * g++.dg/cpp0x/pr69481.C: New.


Since GCC 7.1 we print:

66475.cc:19:11: error: 'using Base = struct Foo<int>' is private within this
context
 Bar<int>::Base x; // shouldn't compile, Base is private
           ^~~~
66475.cc:10:22: note: declared private here
   using Base = Foo<T>; // the combination of this and the public export of a
type from Base below, causes this example to compile even though it shouldn't
                      ^

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

* [Bug c++/66475] Access checking in templates circumvented with 'using' (C++11)
  2015-06-09 16:47 [Bug c++/66475] New: Access checking in templates circumvented with 'using' (C++11) zerolo at gmail dot com
  2015-06-09 16:54 ` [Bug c++/66475] " redi at gcc dot gnu.org
  2020-03-12 15:56 ` redi at gcc dot gnu.org
@ 2021-07-27  8:46 ` pinskia at gcc dot gnu.org
  2021-08-05  7:39 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-07-27  8:46 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66475

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kyle.strand at beckman dot com

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 72780 has been marked as a duplicate of this bug. ***

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

* [Bug c++/66475] Access checking in templates circumvented with 'using' (C++11)
  2015-06-09 16:47 [Bug c++/66475] New: Access checking in templates circumvented with 'using' (C++11) zerolo at gmail dot com
                   ` (2 preceding siblings ...)
  2021-07-27  8:46 ` pinskia at gcc dot gnu.org
@ 2021-08-05  7:39 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-05  7:39 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66475

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mwarusz at gmail dot com

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 67080 has been marked as a duplicate of this bug. ***

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

end of thread, other threads:[~2021-08-05  7:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-09 16:47 [Bug c++/66475] New: Access checking in templates circumvented with 'using' (C++11) zerolo at gmail dot com
2015-06-09 16:54 ` [Bug c++/66475] " redi at gcc dot gnu.org
2020-03-12 15:56 ` redi at gcc dot gnu.org
2021-07-27  8:46 ` pinskia at gcc dot gnu.org
2021-08-05  7:39 ` pinskia 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).