public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/51047] New: [C++0x] SFINAE does not handle errors of ambiguous base members
@ 2011-11-09  4:44 ai.azuma at gmail dot com
  2011-11-09 11:22 ` [Bug c++/51047] " paolo.carlini at oracle dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: ai.azuma at gmail dot com @ 2011-11-09  4:44 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 51047
           Summary: [C++0x] SFINAE does not handle errors of ambiguous
                    base members
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: ai.azuma@gmail.com


I expect that the following code is compiled successfully.
However, the second static_assert results in a hard error without SFINAE.


==========
cryolite@blueplanet:~/work/test$ LANG=C ~/local/4.7.0/bin/g++-tlimit -v
-save-temps -std=c++0x 5_2_5_5.cpp
Using built-in specs.
COLLECT_GCC=/home/cryolite/local/4.7.0/bin/g++
COLLECT_LTO_WRAPPER=/home/cryolite/local/4.7.0/libexec/gcc/x86_64-unknown-linux-gnu/4.7.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /home/cryolite/work/intro/gcc-4.7-20111105/configure
--build=x86_64-unknown-linux-gnu --host=x86_64-unknown-linux-gnu
--target=x86_64-unknown-linux-gnu --prefix=/home/cryolite/local/4.7.0
--enable-static --enable-shared --enable-multilib --enable-threads=posix
--enable-tls --with-arch-32=i686 --with-tune=generic --enable-bootstrap
--enable-languages=c,c++ --enable-libssp --enable-libgomp --enable-targets=all
--enable-nls --enable-lto --enable-libstdcxx-debug --disable-libstdcxx-pch
Thread model: posix
gcc version 4.7.0 20111105 (experimental) (GCC) 
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=c++11' '-shared-libgcc'
'-mtune=generic' '-march=x86-64'
 /home/cryolite/local/4.7.0/libexec/gcc/x86_64-unknown-linux-gnu/4.7.0/cc1plus
-E -quiet -v -D_GNU_SOURCE 5_2_5_5.cpp -mtune=generic -march=x86-64 -std=c++11
-fpch-preprocess -o 5_2_5_5.ii
ignoring nonexistent directory
"/home/cryolite/local/4.7.0/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../x86_64-unknown-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:

/home/cryolite/local/4.7.0/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0

/home/cryolite/local/4.7.0/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/x86_64-unknown-linux-gnu

/home/cryolite/local/4.7.0/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/backward
 /home/cryolite/local/4.7.0/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/include
 /usr/local/include
 /home/cryolite/local/4.7.0/include

/home/cryolite/local/4.7.0/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/include-fixed
 /usr/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=c++11' '-shared-libgcc'
'-mtune=generic' '-march=x86-64'
 /home/cryolite/local/4.7.0/libexec/gcc/x86_64-unknown-linux-gnu/4.7.0/cc1plus
-fpreprocessed 5_2_5_5.ii -quiet -dumpbase 5_2_5_5.cpp -mtune=generic
-march=x86-64 -auxbase 5_2_5_5 -std=c++11 -version -o 5_2_5_5.s
GNU C++ (GCC) version 4.7.0 20111105 (experimental) (x86_64-unknown-linux-gnu)
    compiled by GNU C version 4.7.0 20111105 (experimental), GMP version 5.0.2,
MPFR version 3.0.0-p3, MPC version 0.9
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
GNU C++ (GCC) version 4.7.0 20111105 (experimental) (x86_64-unknown-linux-gnu)
    compiled by GNU C version 4.7.0 20111105 (experimental), GMP version 5.0.2,
MPFR version 3.0.0-p3, MPC version 0.9
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Compiler executable checksum: 1c96d36acbd98a4b9c0fb64069912a60
5_2_5_5.cpp: In substitution of 'template<class T> decltype (declval<T>().x)
f(T*) [with T = D]':
5_2_5_5.cpp:13:27:   required from here
5_2_5_5.cpp:2:44: error: request for member 'x' is ambiguous
5_2_5_5.cpp:5:16: error: candidates are: int B2::x
5_2_5_5.cpp:4:16: error:                 int B1::x

cryolite@blueplanet:~/work/test$ cat 5_2_5_5.ii 
# 1 "5_2_5_5.cpp"
# 1 "<command-line>"
# 1 "5_2_5_5.cpp"
template<typename T> T &&declval();
template<class T> decltype(declval<T>().x) f(T *);
template<class T> char f(T);
struct B1{ int x; };
struct B2{ int x; };
struct D : public B1, B2{};
struct S { int x; };
int main()
{
  S *p = nullptr;
  static_assert(sizeof(f(p)) == sizeof(int), "");
  D *q = nullptr;
  static_assert(sizeof(f(q)) == 1u, "");
}
==========


Just for reference, the following code is compiled without any error as I
expected.


==========
template<class T> decltype(T::x) f(T *);
template<class T> char f(T);
struct B1{ int x; };
struct B2{ int x; };
struct D : public B1, B2{};
struct S { int x; };
int main()
{
  S *p = nullptr;
  static_assert(sizeof(f(p)) == sizeof(int), "");
  D *q = nullptr;
  static_assert(sizeof(f(q)) == 1u, "");
}
==========


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

* [Bug c++/51047] [C++0x] SFINAE does not handle errors of ambiguous base members
  2011-11-09  4:44 [Bug c++/51047] New: [C++0x] SFINAE does not handle errors of ambiguous base members ai.azuma at gmail dot com
@ 2011-11-09 11:22 ` paolo.carlini at oracle dot com
  2011-11-09 17:22 ` paolo at gcc dot gnu.org
  2011-11-09 17:28 ` paolo.carlini at oracle dot com
  2 siblings, 0 replies; 4+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-11-09 11:22 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu.org

--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-11-09 11:07:12 UTC ---
This one seems also easy: looks like finish_class_member_access_expr should
just pass complain to lookup_member. Jason, can you double check? I can do it,
in case.


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

* [Bug c++/51047] [C++0x] SFINAE does not handle errors of ambiguous base members
  2011-11-09  4:44 [Bug c++/51047] New: [C++0x] SFINAE does not handle errors of ambiguous base members ai.azuma at gmail dot com
  2011-11-09 11:22 ` [Bug c++/51047] " paolo.carlini at oracle dot com
@ 2011-11-09 17:22 ` paolo at gcc dot gnu.org
  2011-11-09 17:28 ` paolo.carlini at oracle dot com
  2 siblings, 0 replies; 4+ messages in thread
From: paolo at gcc dot gnu.org @ 2011-11-09 17:22 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> 2011-11-09 17:19:15 UTC ---
Author: paolo
Date: Wed Nov  9 17:19:12 2011
New Revision: 181213

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=181213
Log:
/cp
2011-11-09  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/51047
    * search.c (lookup_member): Change to take also a tsubst_flags_t
    parameter.
    (lookup_field, lookup_fnfields): Adjust calls.
    * typeck.c (lookup_destructor, finish_class_member_access_expr,
    build_ptrmemfunc_access_expr): Likewise.
    * class.c (handle_using_decl, maybe_note_name_used_in_class):
    Likewise.
    * pt.c (resolve_typename_type): Likewise.
    * semantics.c (lambda_function): Likewise.
    * parser.c (cp_parser_perform_range_for_lookup,
    cp_parser_lookup_name): Likewise.
    * friend.c (make_friend_class): Likewise.
    * name-lookup.c (pushdecl_maybe_friend_1, get_class_binding,
    do_class_using_decl, lookup_qualified_name): Likewise.
    * cp-tree.h (lookup_member): Adjust declaration.

/testsuite
2011-11-09  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/51047
    * g++.dg/cpp0x/sfinae29.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/sfinae29.C
Modified:
    trunk/gcc/cp/class.c
    trunk/gcc/cp/cp-tree.h
    trunk/gcc/cp/friend.c
    trunk/gcc/cp/name-lookup.c
    trunk/gcc/cp/parser.c
    trunk/gcc/cp/pt.c
    trunk/gcc/cp/search.c
    trunk/gcc/cp/semantics.c
    trunk/gcc/cp/typeck.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug c++/51047] [C++0x] SFINAE does not handle errors of ambiguous base members
  2011-11-09  4:44 [Bug c++/51047] New: [C++0x] SFINAE does not handle errors of ambiguous base members ai.azuma at gmail dot com
  2011-11-09 11:22 ` [Bug c++/51047] " paolo.carlini at oracle dot com
  2011-11-09 17:22 ` paolo at gcc dot gnu.org
@ 2011-11-09 17:28 ` paolo.carlini at oracle dot com
  2 siblings, 0 replies; 4+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-11-09 17:28 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.7.0

--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-11-09 17:23:34 UTC ---
Fixed.


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

end of thread, other threads:[~2011-11-09 17:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-09  4:44 [Bug c++/51047] New: [C++0x] SFINAE does not handle errors of ambiguous base members ai.azuma at gmail dot com
2011-11-09 11:22 ` [Bug c++/51047] " paolo.carlini at oracle dot com
2011-11-09 17:22 ` paolo at gcc dot gnu.org
2011-11-09 17:28 ` paolo.carlini at oracle 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).