Post B6OY8lNSqcKUhDJfrk by amonakov@mastodon.gamedev.place
 (DIR) More posts by amonakov@mastodon.gamedev.place
 (DIR) Post #B6OXVM239Cc0nLVZoW by wolf480pl@mstdn.io
       0 likes, 0 repeats
       
       can I justvoid foo(const char *arg0, ..., /* , (char*) NULL */) {   const char **argv = &arg0;   /* ... */   execvp(argv[0], argv);}or is that UB?
       
 (DIR) Post #B6OY8lNSqcKUhDJfrk by amonakov@mastodon.gamedev.place
       0 likes, 0 repeats
       
       @wolf480pl Absolutely, UB. Also, has almost no chance of working "as intended" on platforms where arg0 is passed on a register.
       
 (DIR) Post #B6OYFJ3IYhR8sF0Ing by wolf480pl@mstdn.io
       0 likes, 0 repeats
       
       @amonakov duh, for some reason my mental model of varargs was limited to i386
       
 (DIR) Post #B6OYdRmNlMOetHbQlk by amonakov@mastodon.gamedev.place
       0 likes, 0 repeats
       
       @wolf480pl yeah, I wonder if any compilers shipped this sort of crimes in their varargs.h/stdarg.h for i386 (or deliberately tolerated, if the header was shipped separately from the compiler).