Consider the following program:
#include <iostream> typedef void (*fptr)(...); void foo(fptr func) { (*func)(12); } void bar(int x) { std::cout << "bar : " << x << std::endl; } int main() { foo(fptr(bar)); }
This compiles, starts and prints bar : 12 for at least one compiler :) I found this in some outdated code that I have to support, and I wonder if it is safe / defined?
bar does not match the fptr type, so the only way to get this to work is to use an unsafe listing. I think it depends on how the ellipsis magic inside works, is it somehow determined?
Björn pollex
source share