public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/108275] New: GCC accepts invalid program using private data member
@ 2023-01-03 16:41 jlame646 at gmail dot com
  2023-01-03 16:44 ` [Bug c++/108275] " pinskia at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: jlame646 at gmail dot com @ 2023-01-03 16:41 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 108275
           Summary: GCC accepts invalid program using private data member
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jlame646 at gmail dot com
  Target Milestone: ---

The following program is accepted by gcc but rejected by clang and msvc.
https://godbolt.org/z/18fbMYTW7

```

class Base {
  int i;
};

template <auto V>
struct Foo {
  int a;
};


int main()
{
    struct Foo<&Base::i> struct_foo;

}
```

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

* [Bug c++/108275] GCC accepts invalid program using private data member
  2023-01-03 16:41 [Bug c++/108275] New: GCC accepts invalid program using private data member jlame646 at gmail dot com
@ 2023-01-03 16:44 ` pinskia at gcc dot gnu.org
  2023-01-05 19:21 ` [Bug c++/108275] pointer to member field is not checked for accessibility inside a template argument cvs-commit at gcc dot gnu.org
  2023-01-05 19:23 ` ppalka at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-01-03 16:44 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
      Known to fail|                            |4.1.2
   Last reconfirmed|                            |2023-01-03

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
here is a C++98 testcase:
```
class Base {
  int i;
};

template< int Base::* V>
struct Foo {
  int a;
};


int main()
{
    struct Foo<&Base::i> struct_foo;

}
```
Confirmed, not a regression.

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

* [Bug c++/108275] pointer to member field is not checked for accessibility inside a template argument
  2023-01-03 16:41 [Bug c++/108275] New: GCC accepts invalid program using private data member jlame646 at gmail dot com
  2023-01-03 16:44 ` [Bug c++/108275] " pinskia at gcc dot gnu.org
@ 2023-01-05 19:21 ` cvs-commit at gcc dot gnu.org
  2023-01-05 19:23 ` ppalka at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-01-05 19:21 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:

https://gcc.gnu.org/g:12b0d35ec52375da5652d2b8da74083ab700b9d7

commit r13-5037-g12b0d35ec52375da5652d2b8da74083ab700b9d7
Author: Patrick Palka <ppalka@redhat.com>
Date:   Thu Jan 5 14:21:34 2023 -0500

    c++: class-head parsing and CPP_TEMPLATE_ID access [PR108275]

    When tentatively parsing what is really an elaborated-type-specifier
    containing a template-id first as a class-specifier, we may form a
    CPP_TEMPLATE_ID token that later gets reused by the fallback parse if
    the tentative parse fails.  These special tokens also capture the access
    checks that have been deferred while parsing the template-id.  But here
    we form such a token when the access check state is dk_no_check, and so
    the token captures no access checks.  This effectively bypasses access
    checking for the template-id during the subsequent parse as an
    elaborated-type-specifier.

    This patch fixes this by using dk_deferred instead of dk_no_check when
    parsing the class name of a class-head.

            PR c++/108275

    gcc/cp/ChangeLog:

            * parser.cc (cp_parser_class_head): Use dk_deferred instead of
            dk_no_check when parsing the class name.

    gcc/testsuite/ChangeLog:

            * g++.dg/parse/access14.C: New test.

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

* [Bug c++/108275] pointer to member field is not checked for accessibility inside a template argument
  2023-01-03 16:41 [Bug c++/108275] New: GCC accepts invalid program using private data member jlame646 at gmail dot com
  2023-01-03 16:44 ` [Bug c++/108275] " pinskia at gcc dot gnu.org
  2023-01-05 19:21 ` [Bug c++/108275] pointer to member field is not checked for accessibility inside a template argument cvs-commit at gcc dot gnu.org
@ 2023-01-05 19:23 ` ppalka at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: ppalka at gcc dot gnu.org @ 2023-01-05 19:23 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |ppalka at gcc dot gnu.org
   Target Milestone|---                         |13.0
         Resolution|---                         |FIXED
                 CC|                            |ppalka at gcc dot gnu.org
             Status|NEW                         |RESOLVED

--- Comment #3 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed for GCC 13

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

end of thread, other threads:[~2023-01-05 19:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-03 16:41 [Bug c++/108275] New: GCC accepts invalid program using private data member jlame646 at gmail dot com
2023-01-03 16:44 ` [Bug c++/108275] " pinskia at gcc dot gnu.org
2023-01-05 19:21 ` [Bug c++/108275] pointer to member field is not checked for accessibility inside a template argument cvs-commit at gcc dot gnu.org
2023-01-05 19:23 ` 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).