public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/58954] New: accessing a private member function in decltype of a friend class causes access control error
@ 2013-11-01  4:16 myspam456 at gmail dot com
  2013-11-01  6:53 ` [Bug c++/58954] " daniel.kruegler at googlemail dot com
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: myspam456 at gmail dot com @ 2013-11-01  4:16 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 58954
           Summary: accessing a private member function in decltype of a
                    friend class causes access control error
           Product: gcc
           Version: 4.8.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: myspam456 at gmail dot com

When trying to use decltype on a member function which has a late specified
return type calling a private member function of a friend class I receive the
below error.  My understanding is that the "friend struct base<derived>;" in
derived should cause this error to not occur which is the case with clang.  

Adding "foo_argument<derived>" does cause the error to disappear.  

I apologize for the length of the example, but I've had difficulty reproducing
it with fewer lines of code.

main.cpp: In instantiation of ‘struct foo_argument<derived>’:
main.cpp:43:47:   required from here
main.cpp:9:50: error: no matching function for call to
‘foo_argument<derived>::test(<unresolved overloaded function type>)’
     using type = decltype(test(&T::template foo<>));
                                                  ^
main.cpp:9:50: note: candidate is:
main.cpp:7:16: note: template<class Ret, class C, class Arg> static Arg
foo_argument<T>::test(Ret (C::*)(Arg)) [with Ret = Ret; C = C; Arg = Arg; T =
derived]
     static Arg test(Ret (C::*)(Arg));
                ^
main.cpp:7:16: note:   template argument deduction/substitution failed:
main.cpp:35:9: error: ‘int derived::foo_impl(int)’ is private
     int foo_impl(int i)
         ^
main.cpp:9:50: error: within this context
     using type = decltype(test(&T::template foo<>));

The below example can be seen at:
http://coliru.stacked-crooked.com/a/3ffd6557434a3ab9

#include <utility>

template<class T>
struct foo_argument
{
    template<class Ret, class C, class Arg>
    static Arg test(Ret (C::*)(Arg));

    using type = decltype(test(&T::template foo<>));
};

template<class T, class D>
struct dependent { typedef T type; };

template<class T, class D>
using Dependent = typename dependent<T, D>::type;

template<class T>
struct base
{
    friend struct foo_argument<T>;

    template<class Ignore = void>
    auto foo(int i) -> decltype(std::declval<Dependent<T&,
Ignore>>().foo_impl(i))
    {
        return static_cast<T&>(*this).foo_impl(i);
    }
};

struct derived : base<derived>
{
    friend struct base<derived>;
    //friend struct foo_argument<derived>;
  private:
    int foo_impl(int i)
    {
        return 123 + i;
    }
};

int main()
{
    using foo_arg_type = foo_argument<derived>::type;
}
>From gcc-bugs-return-433230-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Fri Nov 01 04:55:07 2013
Return-Path: <gcc-bugs-return-433230-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 3608 invoked by alias); 1 Nov 2013 04:55:07 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 3561 invoked by uid 48); 1 Nov 2013 04:55:03 -0000
From: "su at cs dot ucdavis.edu" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/58955] New: wrong code at -O3 on x86_64-linux-gnu
Date: Fri, 01 Nov 2013 04:55:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: new
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: tree-optimization
X-Bugzilla-Version: 4.9.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: su at cs dot ucdavis.edu
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter
Message-ID: <bug-58955-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2013-11/txt/msg00007.txt.bz2
Content-length: 1506

http://gcc.gnu.org/bugzilla/show_bug.cgi?idX955

            Bug ID: 58955
           Summary: wrong code at -O3 on x86_64-linux-gnu
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: su at cs dot ucdavis.edu

The current gcc trunk miscompiles the following testcase on x86_64-linux-gnu at
-O3 (in both 32-bit and 64-bit modes).

This is a regression from 4.8.x.

$ gcc-trunk -v
Using built-in specs.
COLLECT_GCC=gcc-trunk
COLLECT_LTO_WRAPPER=/usr/local/gcc-trunk/libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-trunk/configure
--enable-languages=c,c++,objc,obj-c++,fortran,lto --disable-werror
--enable-checking=none --with-gmp=/usr/local/gcc-trunk
--with-mpfr=/usr/local/gcc-trunk --with-mpc=/usr/local/gcc-trunk
--with-cloog=/usr/local/gcc-trunk --prefix=/usr/local/gcc-trunk
Thread model: posix
gcc version 4.9.0 20131031 (experimental) [trunk revision 204248] (GCC)
$
$ gcc-trunk -O2 small.c; a.out
1
$ gcc-4.8 -O3 small.c; a.out
1
$ gcc-trunk -O3 small.c; a.out
0
$

------------------------------------


int printf (const char *, ...);

int a, b, c, d[4] = { 0, 0, 0, 1 };

int
main ()
{
  for (; a < 4; a++)
    {
      int e = d[a];
      for (c = 1; c < 1; c++);
      b = e;
      d[a] = 0;
    }
  printf ("%d\n", b);
  return 0;
}


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

* [Bug c++/58954] accessing a private member function in decltype of a friend class causes access control error
  2013-11-01  4:16 [Bug c++/58954] New: accessing a private member function in decltype of a friend class causes access control error myspam456 at gmail dot com
@ 2013-11-01  6:53 ` daniel.kruegler at googlemail dot com
  2013-11-01 11:33 ` [Bug c++/58954] [4.8/4.9 Regression] " paolo.carlini at oracle dot com
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2013-11-01  6:53 UTC (permalink / raw)
  To: gcc-bugs

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

Daniel Krügler <daniel.kruegler at googlemail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |daniel.kruegler@googlemail.
                   |                            |com

--- Comment #1 from Daniel Krügler <daniel.kruegler at googlemail dot com> ---
This seems to be a regression, the example was accepted in gcc 4.7.3.

The following is a first attempt to reduce the complexity of the example, in
particular by removing any library dependencies and any possible interaction
with alias templates and alias typedefs, furthermore the additional friend
declaration in template base is neither needed nor should it be relevant for
this issue, therefore has been removed:

//---------------
template<class T>
T&& declval();

template<class T>
struct foo_argument
{
  template<class Ret, class C, class Arg>
  static Arg test(Ret (C::*)(Arg));

  typedef decltype(test(&T::template foo<>)) type;
};

template<class T, class>
struct dependent { typedef T type; };

template<class T>
struct base
{
  template<class Ignore = void>
  auto foo(int i) -> decltype(declval<
    typename dependent<T&, Ignore>::type
  >().foo_impl(i));
};

struct derived : base<derived>
{
  friend struct base<derived>;
private:
  int foo_impl(int i);
};

int main()
{
  foo_argument<derived>::type var = 0;
  return var;
}
//---------------
>From gcc-bugs-return-433234-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Fri Nov 01 06:56:50 2013
Return-Path: <gcc-bugs-return-433234-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 18551 invoked by alias); 1 Nov 2013 06:56:50 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 18488 invoked by uid 55); 1 Nov 2013 06:56:45 -0000
From: "pault at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/57893] Crash for allocatable character string during compilation.
Date: Fri, 01 Nov 2013 06:56:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: fortran
X-Bugzilla-Version: 4.6.2
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: pault at gcc dot gnu.org
X-Bugzilla-Status: RESOLVED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-57893-4-IcQX1XznvE@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-57893-4@http.gcc.gnu.org/bugzilla/>
References: <bug-57893-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2013-11/txt/msg00011.txt.bz2
Content-length: 506

http://gcc.gnu.org/bugzilla/show_bug.cgi?idW893

--- Comment #2 from Paul Thomas <pault at gcc dot gnu.org> ---
Author: pault
Date: Fri Nov  1 06:56:41 2013
New Revision: 204286

URL: http://gcc.gnu.org/viewcvs?rev 4286&root=gcc&view=rev
Log:
2013-11-01  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/57893
    * gfortran.dg/unlimited_polymorphic_13.f90 : Break up select
    type block.

Modified:
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/unlimited_polymorphic_13.f90


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

* [Bug c++/58954] [4.8/4.9 Regression] accessing a private member function in decltype of a friend class causes access control error
  2013-11-01  4:16 [Bug c++/58954] New: accessing a private member function in decltype of a friend class causes access control error myspam456 at gmail dot com
  2013-11-01  6:53 ` [Bug c++/58954] " daniel.kruegler at googlemail dot com
@ 2013-11-01 11:33 ` paolo.carlini at oracle dot com
  2013-11-01 11:36 ` paolo.carlini at oracle dot com
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-11-01 11:33 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-11-01
                 CC|myspam456 at gmail dot com         |
            Summary|accessing a private member  |[4.8/4.9 Regression]
                   |function in decltype of a   |accessing a private member
                   |friend class causes access  |function in decltype of a
                   |control error               |friend class causes access
                   |                            |control error
     Ever confirmed|0                           |1

--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Thanks Daniel.


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

* [Bug c++/58954] [4.8/4.9 Regression] accessing a private member function in decltype of a friend class causes access control error
  2013-11-01  4:16 [Bug c++/58954] New: accessing a private member function in decltype of a friend class causes access control error myspam456 at gmail dot com
  2013-11-01  6:53 ` [Bug c++/58954] " daniel.kruegler at googlemail dot com
  2013-11-01 11:33 ` [Bug c++/58954] [4.8/4.9 Regression] " paolo.carlini at oracle dot com
@ 2013-11-01 11:36 ` paolo.carlini at oracle dot com
  2013-11-19  9:51 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-11-01 11:36 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2


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

* [Bug c++/58954] [4.8/4.9 Regression] accessing a private member function in decltype of a friend class causes access control error
  2013-11-01  4:16 [Bug c++/58954] New: accessing a private member function in decltype of a friend class causes access control error myspam456 at gmail dot com
                   ` (2 preceding siblings ...)
  2013-11-01 11:36 ` paolo.carlini at oracle dot com
@ 2013-11-19  9:51 ` rguenth at gcc dot gnu.org
  2013-12-13  3:41 ` jason at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-11-19  9:51 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.8.3


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

* [Bug c++/58954] [4.8/4.9 Regression] accessing a private member function in decltype of a friend class causes access control error
  2013-11-01  4:16 [Bug c++/58954] New: accessing a private member function in decltype of a friend class causes access control error myspam456 at gmail dot com
                   ` (3 preceding siblings ...)
  2013-11-19  9:51 ` rguenth at gcc dot gnu.org
@ 2013-12-13  3:41 ` jason at gcc dot gnu.org
  2013-12-13  3:58 ` jason at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jason at gcc dot gnu.org @ 2013-12-13  3:41 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |jason at gcc dot gnu.org
           Assignee|unassigned at gcc dot gnu.org      |jason at gcc dot gnu.org


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

* [Bug c++/58954] [4.8/4.9 Regression] accessing a private member function in decltype of a friend class causes access control error
  2013-11-01  4:16 [Bug c++/58954] New: accessing a private member function in decltype of a friend class causes access control error myspam456 at gmail dot com
                   ` (4 preceding siblings ...)
  2013-12-13  3:41 ` jason at gcc dot gnu.org
@ 2013-12-13  3:58 ` jason at gcc dot gnu.org
  2013-12-13  3:59 ` jason at gcc dot gnu.org
  2013-12-27 22:06 ` jason at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: jason at gcc dot gnu.org @ 2013-12-13  3:58 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Jason Merrill <jason at gcc dot gnu.org> ---
Author: jason
Date: Fri Dec 13 03:58:48 2013
New Revision: 205952

URL: http://gcc.gnu.org/viewcvs?rev=205952&root=gcc&view=rev
Log:
    PR c++/58954
    * pt.c (resolve_overloaded_unification): Use instantiate_template.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/access02.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/pt.c


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

* [Bug c++/58954] [4.8/4.9 Regression] accessing a private member function in decltype of a friend class causes access control error
  2013-11-01  4:16 [Bug c++/58954] New: accessing a private member function in decltype of a friend class causes access control error myspam456 at gmail dot com
                   ` (5 preceding siblings ...)
  2013-12-13  3:58 ` jason at gcc dot gnu.org
@ 2013-12-13  3:59 ` jason at gcc dot gnu.org
  2013-12-27 22:06 ` jason at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: jason at gcc dot gnu.org @ 2013-12-13  3:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jason Merrill <jason at gcc dot gnu.org> ---
Author: jason
Date: Fri Dec 13 03:59:10 2013
New Revision: 205954

URL: http://gcc.gnu.org/viewcvs?rev=205954&root=gcc&view=rev
Log:
    PR c++/58954
    * pt.c (resolve_overloaded_unification): Discard access checks.

Added:
    branches/gcc-4_8-branch/gcc/testsuite/g++.dg/cpp0x/access02.C
Modified:
    branches/gcc-4_8-branch/gcc/cp/ChangeLog
    branches/gcc-4_8-branch/gcc/cp/pt.c


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

* [Bug c++/58954] [4.8/4.9 Regression] accessing a private member function in decltype of a friend class causes access control error
  2013-11-01  4:16 [Bug c++/58954] New: accessing a private member function in decltype of a friend class causes access control error myspam456 at gmail dot com
                   ` (6 preceding siblings ...)
  2013-12-13  3:59 ` jason at gcc dot gnu.org
@ 2013-12-27 22:06 ` jason at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: jason at gcc dot gnu.org @ 2013-12-27 22:06 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #5 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed for 4.8.3/4.9.


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

end of thread, other threads:[~2013-12-27 22:06 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-01  4:16 [Bug c++/58954] New: accessing a private member function in decltype of a friend class causes access control error myspam456 at gmail dot com
2013-11-01  6:53 ` [Bug c++/58954] " daniel.kruegler at googlemail dot com
2013-11-01 11:33 ` [Bug c++/58954] [4.8/4.9 Regression] " paolo.carlini at oracle dot com
2013-11-01 11:36 ` paolo.carlini at oracle dot com
2013-11-19  9:51 ` rguenth at gcc dot gnu.org
2013-12-13  3:41 ` jason at gcc dot gnu.org
2013-12-13  3:58 ` jason at gcc dot gnu.org
2013-12-13  3:59 ` jason at gcc dot gnu.org
2013-12-27 22:06 ` jason 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).