public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/48882] New: ?: ternary operator fails in certain contexts - compile error
@ 2011-05-05 11:42 adele.schmidthammer at yahoo dot de
  2011-05-05 11:55 ` [Bug c++/48882] " adele.schmidthammer at yahoo dot de
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: adele.schmidthammer at yahoo dot de @ 2011-05-05 11:42 UTC (permalink / raw)
  To: gcc-bugs

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: unassigned@gcc.gnu.org
        ReportedBy: adele.schmidthammer@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


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

end of thread, other threads:[~2011-07-07  9:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-05 11:42 [Bug c++/48882] New: ?: ternary operator fails in certain contexts - compile error adele.schmidthammer at yahoo dot de
2011-05-05 11:55 ` [Bug c++/48882] " adele.schmidthammer at yahoo dot de
2011-07-04 22:32 ` [Bug libstdc++/48882] " jason at gcc dot gnu.org
2011-07-07  9:35 ` [Bug libstdc++/48882] [C++0x] " 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).