Re: [PATCH 16/16] fix handling of integer constant expressions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Linus Torvalds wrote:-

> > extern int f(void);
> > enum { cast_to_ptr = (int) (void *) 0 };
> > enum { cast_to_float = (int) (double) 1 };
> 
> Those two *really* shouldn't fail. I don't care if the C standard says so, 
> that is *fine*.
> 
> In particular, "offsetof()" should be portably able to basically be the 
> standard #define, which involves an integer cast from a constant pointer. 
> That had *better* be a valid constant integer expression, because it's 
> very useful.
> 
> And I think standards can go screw themselves, and you can make it an 
> error with some "--standard-pedantic" switch or similar.
> 
> Standards are just random pieces of paper, for crying out loud! They have 
> zero relevance in the end. 
> 
> > enum { fncall = 0 ? f(): 3 };
> 
> Again, I think that's a deficiency of a standard that tries to be 
> acceptable to everybody rather than about a "really good language".

Yes, I think what you're saying is widely understood.  However I think
Al's original goal was to do strictly what the standard said, and then
maybe loosen up parts than arguably make sense much like you describe.

My examples were just to help him get semantics matching a strict
reading of the standard, not suggest what the default handling might
be or what is actually a good idea in practice.  I think if you don't
follow the "strictly correct then loosen up" approach it's easy to
get an ill-defined end result, much like current GCC.

Neil.
-
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux