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]

Re: Strange C++ function pointer test


On Thu, Dec 31, 2015 at 12:45:06PM +0100, Marc Glisse wrote:
> On Thu, 31 Dec 2015, Dominik Vogt wrote:
> 
> >The minimal failing program is
> >
> >-- abs.C --
> >#include <stdlib.h>
> >static float (*p1_)(float) = abs;
> >-- abs.C --
> 
> This is allowed to fail. If you include math.h (in addition or
> instead of stdlib.h), it has to work (gcc bug if it doesn't).
> 
> See also
> http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#2294

Understood.  So, this should work in any case but doesn't

-- abs.C --
#include <stdlib.h>
#include <math.h>
static float (*p1_)(float) = abs;
-- abs.C --

$ g++ -std=c++11 abs.C -Wsystem-headers
abs.C:3:30: error: invalid conversion from âint (*)(int) throw ()â to âfloat (*)(float)â [-fpermissive]
 static float (*p1_)(float) = abs;
                                ^~~

Is there a requirement for a certain minimum Glibc version for
this to work?

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]