Boost logo

Boost :

From: Jens Maurer (Jens.Maurer_at_[hidden])
Date: 2001-10-26 19:20:26


"George A. Heintzelman" wrote:
> 2) (More troublesome) in once.cpp,

> /work/nova/2465/once.cpp: In function `void {anonymous}::do_once()':
> /work/nova/2465/once.cpp:41: ANSI C++ forbids casting between pointers
> to functions and objects
>
> This is, I think, strictly correct. It is arguably a flaw in the
> standard that a pointer to an extern "C" function cannot be converted
> back and forth with a void *, since C allows that behavior, but I could
> find nothing in the standard that excepted extern "C" functions from
> the conversion rules.

It appears that an upcoming revision of the C++ standard will fix
this problem by allowing the conversion, but making its behaviour
undefined, i.e. compilers are not required to give an error about this
at compile-time any more. Note that any program relying on the cast
to work correctly is non-portable, though.

See the core issues list of the C++ standardization committee, issue 195.

Jens Maurer


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk