[systemd-devel] compile with clang broken
David Herrmann
dh.herrmann at gmail.com
Fri Aug 15 03:35:13 PDT 2014
Hi
On Fri, Aug 15, 2014 at 12:29 PM, Thomas H.P. Andersen <phomes at gmail.com> wrote:
> On Fri, Aug 15, 2014 at 11:49 AM, David Herrmann <dh.herrmann at gmail.com> wrote:
>> Thanks for trying!
>>
>> Result is as I expected. Evaluation takes place _after_ validating
>> compile-time constants, and thus __builtin_constant_p in combination
>> with ?: will not work if not both cases are constant. Maybe it works
>> with __builtin_choose_expr()?
>>
>> Can you try the attached patch?
>
> This patch works. It also needs the change to do the calculation to a
> seperate line. Also only if size is const, like so:
> const size_t size = MAX(sizeof(struct in_pktinfo), sizeof(struct in6_pktinfo));
Again, thanks for trying it out!
I don't understand your comment, though. You're saying this works:
const size_t size = MAX(...);
uint8_t buffer[CMSG_SPACE(size) +...];
...but this doesn't work:
uint8_t buffer[CMSG_SPACE(MAX(...)) +...];
...and this doesn't work either (mind the dropped 'const'):
size_t size = MAX(...);
uint8_t buffer[CMSG_SPACE(size) +...];
Hm. This is weird. Maybe CMSG_SPACE does something weird. I'll see.
David
More information about the systemd-devel
mailing list