http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48882
Summary: ?: ternary operator fails in certain contexts - compile error Product: gcc Version: 4.7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: adele.schmidtham...@yahoo.de #include<algorithm> // std::max std::min #include<iostream> int main() { int a = 1000; int b = 2000; bool even = true; const int& (*fp)(const int&, const int&); fp = even ? std::max<int> : std::min<int>; /* does not compile! */ std::cout << fp(a,b) << std::endl; } Error message: insufficient contextual information to determine type however if(even) fp = std::max<int>; else fp = std::min<int>; works as expected: Output of compilation: Es werden eingebaute Spezifikationen verwendet. COLLECT_GCC=/home/me/programme/gcc47/bin/g++ COLLECT_LTO_WRAPPER=/home/me/programme/gcc47/libexec/gcc/i686-pc-linux-gnu/4.7.0/lto-wrapper Ziel: i686-pc-linux-gnu Konfiguriert mit: ./configure --prefix=/home/me/programme/gcc47 Thread-Modell: posix gcc-Version 4.7.0 20110430 (experimental) (GCC) COLLECT_GCC_OPTIONS='-v' '-std=c++0x' '-Wall' '-save-temps' '-shared-libgcc' '-mtune=generic' '-march=pentiumpro' /home/me/programme/gcc47/libexec/gcc/i686-pc-linux-gnu/4.7.0/cc1plus -E -quiet -v -D_GNU_SOURCE bug1.cpp -mtune=generic -march=pentiumpro -std=c++0x -Wall -fpch-preprocess -o bug1.ii nicht vorhandenes Verzeichnis »/home/me/programme/gcc47/lib/gcc/i686-pc-linux-gnu/4.7.0/../../../../i686-pc-linux-gnu/include« wird ignoriert #include "..." - Suche beginnt hier: #include <...> - Suche beginnt hier: /home/me/programme/gcc47/lib/gcc/i686-pc-linux-gnu/4.7.0/../../../../include/c++/4.7.0 /home/me/programme/gcc47/lib/gcc/i686-pc-linux-gnu/4.7.0/../../../../include/c++/4.7.0/i686-pc-linux-gnu /home/me/programme/gcc47/lib/gcc/i686-pc-linux-gnu/4.7.0/../../../../include/c++/4.7.0/backward /home/me/programme/gcc47/lib/gcc/i686-pc-linux-gnu/4.7.0/include /usr/local/include /home/me/programme/gcc47/include /home/me/programme/gcc47/lib/gcc/i686-pc-linux-gnu/4.7.0/include-fixed /usr/include Ende der Suchliste. COLLECT_GCC_OPTIONS='-v' '-std=c++0x' '-Wall' '-save-temps' '-shared-libgcc' '-mtune=generic' '-march=pentiumpro' /home/me/programme/gcc47/libexec/gcc/i686-pc-linux-gnu/4.7.0/cc1plus -fpreprocessed bug1.ii -quiet -dumpbase bug1.cpp -mtune=generic -march=pentiumpro -auxbase bug1 -Wall -std=c++0x -version -o bug1.s GNU C++ (GCC) Version 4.7.0 20110430 (experimental) (i686-pc-linux-gnu) kompiliert von GNU-C-Version 4.7.0 20110430 (experimental), GMP-Version 5.0.1, MPFR-Version 3.0.0-p3, MPC-Version 0.8.2. GGC-Heuristik: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 GNU C++ (GCC) Version 4.7.0 20110430 (experimental) (i686-pc-linux-gnu) kompiliert von GNU-C-Version 4.7.0 20110430 (experimental), GMP-Version 5.0.1, MPFR-Version 3.0.0-p3, MPC-Version 0.8.2. GGC-Heuristik: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 Compiler executable checksum: c95befb475332395eb1695ad61c47f68 bug1.cpp: In Funktion »int main()«: bug1.cpp:19:38: Fehler: insufficient contextual information to determine type bug1.cpp:19:38: Fehler: insufficient contextual information to determine type