Conversation

C PSA/periodic reminder: YOU CANNOT CALL A VARIADIC FUNCTION VIA AN EXPRESSION OF NON-VARIADIC FUNCTION TYPE MATCHING THE ARGS YOU WANT TO USE, OR VICE VERSA!
2
7
Replying to
By casting a function pointer? I'd never even thought to try it, but now that you mention it, I certainly wouldn't expect it to work, though it might by accident on ancient systems that always pass args on stack.
1
Replying to and
No, because C type information is lost compiling to bytecode. There's no error even with a more egregious violation. Needs a compile-time sanitizer. % cat a.c int foo(void) { return 1; } % cat b.c void foo(int x); void bar() { foo(5); } % clang a.c b.c -flto -shared
2
Show replies