|
Message-ID: <20130109211128.GZ17059@headless> Date: Wed, 9 Jan 2013 21:11:28 +0000 From: Rob <robpilling@...il.com> To: musl@...ts.openwall.com Subject: Re: NULL On Wed, Jan 09, 2013 at 10:36:30AM -0500, Rich Felker wrote: > i.e. confusion of NULL with ASCII NUL. However, this raises a good > question: short of C11 _Generic, is it even possible for a program to > detect whether NULL has integer or pointer type? > > I know of one way, but it's very obscure: > > int null_is_ptr_type() > { > char s[1][1+(int)NULL]; > int i = 0; > return sizeof s[i++], i; > } Magic... is `s' a VLA here? My mind is boggled because __builtin_constant_p(1+(int)NULL) returns 1, and I can't think of any reason why the sizeof is evaluated. Also, seeing that clang and tcc return 0 in all cases, is this a bug in both of them? Cheers, Rob
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.