Re:Defining the Undefinedness of C (2015) [pdf]
by simias on Wednesday July 26, 2017 @01:00PM
(#14857974)
But what if it's the result of some inlining or simply macro expansion? It's a tough call to make.
[ Parent
| on HN ]
Re:Defining the Undefinedness of C (2015) [pdf]
by inetknght on Wednesday July 26, 2017 @01:37PM
(#14858299)
If it's from inlining, then the compiler has a bug. If it's from a macro, then stop using macros in a broken fashion. Let it be an error.
Re:Defining the Undefinedness of C (2015) [pdf]
by jjnoakes on Wednesday July 26, 2017 @04:02PM
(#14859728)
How would that be a compiler bug? Assuming g() is never called with a NULL pointer, this code should not produce any compile-time errors:
int f(int *x)
{
if (x == NULL) return 0;
return *x;
}
int g(int *p)
{
return (*p) + f(p);
}