Boost logo

Boost :

From: Jim Apple (japple_at_[hidden])
Date: 2003-12-26 18:48:18


Aside: Beman, here's an Intel bug to report.

David Abrahams wrote:
> the compiler bug doesn't affect the usability of Boost.Function

I disagree. I wouldn't be concerned if this error caused working code,
but Doug pointed out some code that should fail at compile time that
instead fails silently at runtime.

Is there really any worse type of usability error? 8-)

> and
> it interacts with *any* code which does function pointer/reference
> assignment.

I'm not sure I understand this statement. If you mean it this file
would compile (and cause the test to fail) for function
pointer/reference, then I disagree. The compilers I tested emmitted the
proper errors for non boost::function use.

Example:
--------------------------------------------------------
void f(int = 0) {}
 

void (*g)(int) = f;
 

struct indirect {
   void (*call)();
   template<typename FType>
   void attempt(FType * p) {
     reinterpret_cast<FType *>(call)();
   }
   /*
   void attempt_fail() {
     reinterpret_cast<void (*)(int)>(call)();
   }
   */
   indirect(void (*p)(int)) : call(reinterpret_cast<void (*)()>(p)) {}
};
 

int main() {
   indirect x(f);
   x.attempt(f);
   //g();
}
--------------------------------------------------------

Uncommenting indirect::attempt_fail causes a "too few arguments" compile
error, as does uncommenting g(). However, g++ 3.3.1 and icc 8 both pass
this with no errors, with -strict_ansi and -pedantic, respectively.

Jim


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