[prev in list] [next in list] [prev in thread] [next in thread]
List: gcc-bugs
Subject: Re: cannot convert `int (*)()' to `void*' in initialization - should not be an error
From: DJ Delorie <dj () redhat ! com>
Date: 2001-05-31 20:12:38
[Download RAW message or body]
Carlo Wood <carlo@alinoe.com> writes:
> I noticed this too (and had to add a cast). What is the reason
> that C++ doesn't allow this? I don't like casts, they normally
> lead to bugs later on. What is the pitfal in this case?
On some machines, such as RISC machines that always have word-aligned
opcodes, the LSBs in function pointers may be used for other purposes
(say, the type of function or some chip-specific variations - see
arm/thumb for examples). In those cases, the pointer to the function
does *not* point to the beginning of the function! Casting it will
not result in a usable pointer. You must *tell* gcc to reinterpret
the function pointer as a data pointer so that it adjusts the value in
the pointer to make it usable.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic