This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/50324] New: SFINAE does not handle the object creation of an incomplete type


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

             Bug #: 50324
           Summary: SFINAE does not handle the object creation of an
                    incomplete type
    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


As far as I understand correctly, the following code should be compiled
successfully.
However, the latter static_assert results in a hard error without SFINAE.


cryolite@blueplanet:~/work/test$ LANG=C "/home/cryolite/local/4.7.0/bin/g++" -v
-save-temps -std=c++0x -c "main.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: ../gcc-4.7-20110820/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-shared --enable-multilib
--enable-threads --enable-tls --enable-languages=c,c++ --enable-nls
--enable-lto --enable-libstdcxx-debug --disable-libstdcxx-pch
Thread model: posix
gcc version 4.7.0 20110820 (experimental) (GCC) 
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=c++0x' '-c' '-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 main.cpp -mtune=generic -march=x86-64 -std=c++0x
-fpch-preprocess -o main.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++0x' '-c' '-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 main.ii -quiet -dumpbase main.cpp -mtune=generic -march=x86-64
-auxbase main -std=c++0x -version -o main.s
GNU C++ (GCC) version 4.7.0 20110820 (experimental) (x86_64-unknown-linux-gnu)
        compiled by GNU C version 4.7.0 20110820 (experimental), GMP version
5.0.2, MPFR version 3.0.1, MPC version 0.9
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
GNU C++ (GCC) version 4.7.0 20110820 (experimental) (x86_64-unknown-linux-gnu)
        compiled by GNU C version 4.7.0 20110820 (experimental), GMP version
5.0.2, MPFR version 3.0.1, MPC version 0.9
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Compiler executable checksum: 93b10bde50b693a2f5890ff9c833cb57
main.cpp: In substitution of 'template<class T> decltype ({})* f(T*) [with T =
incomplete]':
main.cpp:10:27:   required from here
main.cpp:3:24: error: invalid use of incomplete type 'struct incomplete'
main.cpp:2:8: error: forward declaration of 'struct incomplete'

cryolite@blueplanet:~/work/test$ cat main.ii
# 1 "main.cpp"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "main.cpp"
struct complete{};
struct incomplete;
template<class T> auto f(T *) -> decltype(T{}) *;
template<class T> char f(T);
int main()
{
  complete *p = 0;
  static_assert(sizeof(f(p)) == sizeof(void*), "");
  incomplete *q = 0;
  static_assert(sizeof(f(q)) == 1u, "");
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]