public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/51213] New: [C++11][DR 1170] Access control checking has to be done under SFINAE conditions
@ 2011-11-18 20:10 daniel.kruegler at googlemail dot com
  2012-04-04 13:56 ` [Bug c++/51213] " paolo.carlini at oracle dot com
                   ` (21 more replies)
  0 siblings, 22 replies; 23+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2011-11-18 20:10 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 51213
           Summary: [C++11][DR 1170] Access control checking has to be
                    done under SFINAE conditions
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: daniel.kruegler@googlemail.com
                CC: jason@gcc.gnu.org


gcc 4.7 20111112 (experimental) in C++11 mode rejects the following code:

//---
class C {
  typedef int type; // Line 2
};

template<class T, class = typename T::type>
auto f(int) -> char;

template<class>
auto f(...) -> char (&)[2];

static_assert(sizeof(f<C>(0)) == 2, "Ouch"); // Line 11

template<class T>
auto g(int) -> decltype(typename T::type(), char());

template<class>
auto g(...) -> char (&)[2];

static_assert(sizeof(g<C>(0)) == 2, "Ouch"); // Line 19

int main() {}
//---

"main.cpp|11|error: static assertion failed: "Ouch"|
main.cpp||In function 'decltype ((typename T::type(), char())) g(int) [with T =
C; decltype ((typename T::type(), char())) = char; typename T::type = int]':|
main.cpp|2|error: 'typedef int C::type' is private|
main.cpp|19|error: within this context|
main.cpp|19|error: static assertion failed: "Ouch"|"

After approval of DR 1170:

http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1170

access checking has become part of the template substitution process as
described in 14.8.2 p8:

"If a substitution results in an invalid type or expression, type deduction
fails. An invalid type or expression is one that would be ill-formed if written
using the substituted arguments. [ Note: Access checking is done as part of the
substitution process. —end note ] [..]"

This means as of C++11 above program should be accepted.


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

end of thread, other threads:[~2014-10-22  9:25 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-18 20:10 [Bug c++/51213] New: [C++11][DR 1170] Access control checking has to be done under SFINAE conditions daniel.kruegler at googlemail dot com
2012-04-04 13:56 ` [Bug c++/51213] " paolo.carlini at oracle dot com
2012-04-20  2:10 ` paolo.carlini at oracle dot com
2012-04-27  1:33 ` jyasskin at gcc dot gnu.org
2012-04-27  9:27 ` paolo.carlini at oracle dot com
2012-06-20 19:10 ` redi at gcc dot gnu.org
2012-07-19  1:38 ` jason at gcc dot gnu.org
2012-07-19  2:06 ` jason at gcc dot gnu.org
2012-07-23 21:02 ` daniel.kruegler at googlemail dot com
2012-07-23 23:36 ` paolo.carlini at oracle dot com
2012-07-24 10:35 ` paolo.carlini at oracle dot com
2012-08-02 18:46 ` paolo at gcc dot gnu.org
2012-08-02 19:38 ` paolo.carlini at oracle dot com
2012-08-25  3:31 ` jason at gcc dot gnu.org
2012-08-31 12:58 ` markus at trippelsdorf dot de
2012-09-04 18:51 ` jason at gcc dot gnu.org
2013-06-23 20:28 ` w.shane.grant at gmail dot com
2013-06-23 22:05 ` paolo.carlini at oracle dot com
2014-10-22  5:29 ` mizvekov at gmail dot com
2014-10-22  6:39 ` mizvekov at gmail dot com
2014-10-22  9:01 ` paolo.carlini at oracle dot com
2014-10-22  9:24 ` paolo.carlini at oracle dot com
2014-10-22  9:30 ` mizvekov at gmail dot com

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).