public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/48883] New: ?: ternary operator fails in certain contexts - link error
@ 2011-05-05 11:46 adele.schmidthammer at yahoo dot de
  2011-05-05 12:02 ` [Bug c++/48883] " adele.schmidthammer at yahoo dot de
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: adele.schmidthammer at yahoo dot de @ 2011-05-05 11:46 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: ?: ternary operator fails in certain contexts - link
                    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


probably there is a relation to bug 48882

I do not attach the precompiled file (.ii), because it is too big.

#include<algorithm> // std::max  std::min
#include<iostream>

template<typename T>
const T& myMin(const T& a, const T& b) {
   if(a < b) return a;
   return b;
}
template<typename T>
const T& myMax(const T& a, const T& b) {
   if(a > b) return a;
   return b;
}

int main() {
   int a = 1000;
   int b = 2000;
   bool even = true;
   const int& (*fp)(const int&, const int&);
   fp = even ? myMax<int> : myMin<int>;   /* yields link error */
    std::cout << fp(a,b) << std::endl;
}

does not link. Output :

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 bug2.cpp -mtune=generic -march=pentiumpro -std=c++0x -Wall
-fpch-preprocess -o bug2.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 bug2.ii -quiet -dumpbase bug2.cpp -mtune=generic
-march=pentiumpro -auxbase bug2 -Wall -std=c++0x -version -o bug2.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
COLLECT_GCC_OPTIONS='-v' '-std=c++0x' '-Wall' '-save-temps' '-shared-libgcc'
'-mtune=generic' '-march=pentiumpro'
 as --32 -o bug2.o bug2.s
COMPILER_PATH=/home/me/programme/gcc47/libexec/gcc/i686-pc-linux-gnu/4.7.0/:/home/me/programme/gcc47/libexec/gcc/i686-pc-linux-gnu/4.7.0/:/home/me/programme/gcc47/libexec/gcc/i686-pc-linux-gnu/:/home/me/programme/gcc47/lib/gcc/i686-pc-linux-gnu/4.7.0/:/home/me/programme/gcc47/lib/gcc/i686-pc-linux-gnu/
LIBRARY_PATH=/home/me/programme/gcc47/lib/gcc/i686-pc-linux-gnu/4.7.0/:/home/me/programme/gcc47/lib/gcc/i686-pc-linux-gnu/4.7.0/../../../:/lib/:/usr/lib/
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/collect2
--eh-frame-hdr -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 /usr/lib/crt1.o
/usr/lib/crti.o
/home/me/programme/gcc47/lib/gcc/i686-pc-linux-gnu/4.7.0/crtbegin.o
-L/home/me/programme/gcc47/lib/gcc/i686-pc-linux-gnu/4.7.0
-L/home/me/programme/gcc47/lib/gcc/i686-pc-linux-gnu/4.7.0/../../.. bug2.o
-lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc
/home/me/programme/gcc47/lib/gcc/i686-pc-linux-gnu/4.7.0/crtend.o
/usr/lib/crtn.o
bug2.o: In function `main':
bug2.cpp:(.text+0x26): undefined reference to `int const& myMax<int>(int
const&, int const&)'
bug2.cpp:(.text+0x2d): undefined reference to `int const& myMin<int>(int
const&, int const&)'
collect2: ld gab 1 als Ende-Status zurück


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

* [Bug c++/48883] ?: ternary operator fails in certain contexts - link error
  2011-05-05 11:46 [Bug c++/48883] New: ?: ternary operator fails in certain contexts - link error adele.schmidthammer at yahoo dot de
@ 2011-05-05 12:02 ` adele.schmidthammer at yahoo dot de
  2011-05-05 12:15 ` redi at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: adele.schmidthammer at yahoo dot de @ 2011-05-05 12:02 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Adele Schmidt <adele.schmidthammer at yahoo dot de> 2011-05-05 11:49:25 UTC ---
However

     if(even) fp = myMax<int>;
     else     fp = myMin<int>;

does work as expected.


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

* [Bug c++/48883] ?: ternary operator fails in certain contexts - link error
  2011-05-05 11:46 [Bug c++/48883] New: ?: ternary operator fails in certain contexts - link error adele.schmidthammer at yahoo dot de
  2011-05-05 12:02 ` [Bug c++/48883] " adele.schmidthammer at yahoo dot de
@ 2011-05-05 12:15 ` redi at gcc dot gnu.org
  2011-07-01 16:43 ` jason at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2011-05-05 12:15 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2011.05.05 12:15:05
     Ever Confirmed|0                           |1

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-05-05 12:15:05 UTC ---
reduced:

template<typename T>
T myMax(T a, T b) {
   if(a < b) return a;
   return b;
}

int main() {
   bool even = true;
   int (*fp)(int, int);
   fp = even ? myMax<int> : myMax<int>;   /* yields link error */
}


The function template specialization should be implicitly instantiated


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

* [Bug c++/48883] ?: ternary operator fails in certain contexts - link error
  2011-05-05 11:46 [Bug c++/48883] New: ?: ternary operator fails in certain contexts - link error adele.schmidthammer at yahoo dot de
  2011-05-05 12:02 ` [Bug c++/48883] " adele.schmidthammer at yahoo dot de
  2011-05-05 12:15 ` redi at gcc dot gnu.org
@ 2011-07-01 16:43 ` jason at gcc dot gnu.org
  2011-07-01 16:51 ` redi at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jason at gcc dot gnu.org @ 2011-07-01 16:43 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |jason at gcc dot gnu.org
         AssignedTo|unassigned at gcc dot       |jason at gcc dot gnu.org
                   |gnu.org                     |


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

* [Bug c++/48883] ?: ternary operator fails in certain contexts - link error
  2011-05-05 11:46 [Bug c++/48883] New: ?: ternary operator fails in certain contexts - link error adele.schmidthammer at yahoo dot de
                   ` (2 preceding siblings ...)
  2011-07-01 16:43 ` jason at gcc dot gnu.org
@ 2011-07-01 16:51 ` redi at gcc dot gnu.org
  2011-07-01 17:56 ` jason at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2011-07-01 16:51 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-07-01 16:50:36 UTC ---
Is this related to http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49609#c2 ?

The ternary operator is not one of the contexts listed in 13.4 [over.over] p1
either.  The explicit argument list uniquely identifies the specialization, so
myMax<int> is an lvalue for the function template, but I don't see any 
requirement that it gets instantiated


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

* [Bug c++/48883] ?: ternary operator fails in certain contexts - link error
  2011-05-05 11:46 [Bug c++/48883] New: ?: ternary operator fails in certain contexts - link error adele.schmidthammer at yahoo dot de
                   ` (3 preceding siblings ...)
  2011-07-01 16:51 ` redi at gcc dot gnu.org
@ 2011-07-01 17:56 ` jason at gcc dot gnu.org
  2011-07-01 20:26 ` jason at gcc dot gnu.org
  2011-07-01 20:53 ` jason at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: jason at gcc dot gnu.org @ 2011-07-01 17:56 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |srk31 at srcf dot ucam.org

--- Comment #4 from Jason Merrill <jason at gcc dot gnu.org> 2011-07-01 17:54:27 UTC ---
*** Bug 49609 has been marked as a duplicate of this bug. ***


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

* [Bug c++/48883] ?: ternary operator fails in certain contexts - link error
  2011-05-05 11:46 [Bug c++/48883] New: ?: ternary operator fails in certain contexts - link error adele.schmidthammer at yahoo dot de
                   ` (4 preceding siblings ...)
  2011-07-01 17:56 ` jason at gcc dot gnu.org
@ 2011-07-01 20:26 ` jason at gcc dot gnu.org
  2011-07-01 20:53 ` jason at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: jason at gcc dot gnu.org @ 2011-07-01 20:26 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Jason Merrill <jason at gcc dot gnu.org> 2011-07-01 20:24:16 UTC ---
Author: jason
Date: Fri Jul  1 20:24:08 2011
New Revision: 175764

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=175764
Log:
    PR c++/48883
    PR c++/49609
    * pt.c (resolve_nondeduced_context): Call mark_used.

Added:
    trunk/gcc/testsuite/g++.dg/template/explicit-args4.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/pt.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug c++/48883] ?: ternary operator fails in certain contexts - link error
  2011-05-05 11:46 [Bug c++/48883] New: ?: ternary operator fails in certain contexts - link error adele.schmidthammer at yahoo dot de
                   ` (5 preceding siblings ...)
  2011-07-01 20:26 ` jason at gcc dot gnu.org
@ 2011-07-01 20:53 ` jason at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: jason at gcc dot gnu.org @ 2011-07-01 20:53 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

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

--- Comment #6 from Jason Merrill <jason at gcc dot gnu.org> 2011-07-01 20:51:38 UTC ---
Fixed for 4.7.


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

end of thread, other threads:[~2011-07-01 20:53 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-05 11:46 [Bug c++/48883] New: ?: ternary operator fails in certain contexts - link error adele.schmidthammer at yahoo dot de
2011-05-05 12:02 ` [Bug c++/48883] " adele.schmidthammer at yahoo dot de
2011-05-05 12:15 ` redi at gcc dot gnu.org
2011-07-01 16:43 ` jason at gcc dot gnu.org
2011-07-01 16:51 ` redi at gcc dot gnu.org
2011-07-01 17:56 ` jason at gcc dot gnu.org
2011-07-01 20:26 ` jason at gcc dot gnu.org
2011-07-01 20:53 ` jason at gcc dot gnu.org

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).