[systemd-devel] compile with clang broken
David Herrmann
dh.herrmann at gmail.com
Fri Aug 15 04:00:09 PDT 2014
Hi
On Fri, Aug 15, 2014 at 12:40 PM, Thomas H.P. Andersen <phomes at gmail.com> wrote:
> On Fri, Aug 15, 2014 at 12:35 PM, David Herrmann <dh.herrmann at gmail.com> wrote:
>> 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!
>
> no problem. I have inserted the relevant error messages for the two
> non-working cases.
>
>> 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(...)) +...];
>
> src/resolve/resolved-dns-stream.c:67:43: error: non-const static data
> member must be initialized out of line
> uint8_t buffer[CMSG_SPACE(MAX(sizeof(struct
> in_pktinfo), sizeof(struct in6_pktinfo)))
> ^
Ok, this can be fixed by adding "const" to the variables inside the ({
}) else-clause. But we then end up with:
error: statement expression not allowed at file scope
Hmm..
More information about the systemd-devel
mailing list