gmp-5.0.5 gmpxx ternary operator doesn't compile with shift operator

Helmut Jarausch jarausch at skynet.be
Sat May 12 16:16:23 CEST 2012


The following code does not compile with gcc-4.6.3

#include <gmpxx.h>

mpf_class power(const mpf_class& x) {
  int pwr = 2;
  
  return ( pwr < 0 ? (x>> -pwr) : (x << pwr) );
}


I get:

In function 'mpf_class power(const mpf_class&)':
gmpxx-bug.C:6:44: error: no match for ternary 'operator?:' in '(pwr < 
0) ? operator>> [with T = __mpf_struct [1], U = __mpf_struct [1]]((* & 
x), ((long unsigned int)(- pwr))) : operator<< [with T = __mpf_struct 
[1], U = __mpf_struct [1]]((* & x), ((long unsigned int)pwr))'


I get the same error with gcc-4.8.0 (git).

Many thanks for any comments,
Helmut.


More information about the gmp-bugs mailing list