This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/49399] [C++0x] substitution failure error
- From: "jarrydb at cse dot unsw.edu.au" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 14 Jun 2011 12:21:38 +0000
- Subject: [Bug c++/49399] [C++0x] substitution failure error
- Auto-submitted: auto-generated
- References: <bug-49399-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49399
--- Comment #4 from Jarryd Beck <jarrydb at cse dot unsw.edu.au> 2011-06-14 12:21:15 UTC ---
(In reply to comment #3)
> The program should not compile.
>
> In C++03 it should fail to compile because it accesses a private member. SFINAE
> does not take access control into account in C++03, so that is an error. G++
> fails to reject the program because access checking in templates is buggy.
>
> There was a last minute change in the C++0x FDIS to make SFINAE consider access
> control. The previous draft
> (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf) says in
> section 14.8.2 [temp.deduct] p8 "Access checking is not done as part of the
> substitution process. Consequently, when deduction succeeds, an access error
> could still result when the function is instantiated."
> That was changed in the FDIS, so accessing the private member should cause
> deduction to fail, so there is no broken_fun and the call to it in main should
> fail. G++ 4.7 doesn't implement that change yet, so rejects the program for
> the wrong reason.
>
> If you had a second, less specific, overload of broken_fun then the program
> would still be invalid in C++03 but should be well-formed in C++0x. G++ doesn't
> accept it because access checking is not done as part of the substitution
> process yet.
>
> e.g. this is valid C++0x
>
> struct broken
> {
> private:
> typedef int value_type;
> };
>
> template <typename T>
> int
> broken_fun(int, typename T::value_type* = 0);
>
> template <typename T>
> char
> broken_fun(...);
>
> int main(int argc, char* argv[])
> {
>
> return sizeof(broken_fun<broken>(5));
> }
Ah, I see. Well the example you gave also doesn't compile. This is exactly what
the boost library does too, I missed that part in their code, meaning that
parts of boost no longer compile with gcc 4.7.