This is the mail archive of the gcc@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]

Strange C++ function pointer test


This snippet ist from the Plumhall 2014 xvs test suite:

  #if CXX03 || CXX11 || CXX14 
  static float (*p1_)(float) = abs; 
  ...
  checkthat(__LINE__, p1_ != 0);
  #endif

(With the testsuite specific macros doing the obvious).  abs() is
declared as:

  int abs(int j)

Am I missing some odd C++ feature or is that part of the test just
plain wrong?  I don't know where to look in the C++ standard; is
this supposed to compile (with or without a warning?) or generate
an error or is it just undefined?

  error: invalid conversion from âint (*)(int) throw ()â to âfloat (*)(float)â [-fpermissive]

(Of course even with -fpermissive this won't work because (at
least on my platform) ints are passed in different registers than
floats.)

Ciao

Dominik ^_^  ^_^

-- 

Dominik Vogt
IBM Germany


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