[systemd-devel] compile with clang broken

Lennart Poettering lennart at poettering.net
Fri Aug 15 04:53:41 PDT 2014


On Fri, 15.08.14 13:42, David Herrmann (dh.herrmann at gmail.com) wrote:

> 
> Hi
> 
> On Fri, Aug 15, 2014 at 1:22 PM, Lennart Poettering
> <lennart at poettering.net> wrote:
> > On Fri, 15.08.14 13:00, David Herrmann (dh.herrmann at gmail.com) wrote:
> >
> >> > 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
> >
> > I wonder if there's *any* way how to implement a double-evalutation-free
> > all-type MAX() on LLVM... That'd be quite a limitation in LLVM...
> 
> I looked around and it seems like there's nothing we can do. Weird
> thing is, LLVM allows const-initialization but not member-definition
> with that macro. I really don't understand why..
> 
> I somehow think adding MAX_CONST which uses __builtin_constant_p and
> assert_cc() is the easiest way here. That is, we use MAX_CONST() for
> all cases where MAX fails. I think this is the easiest way to
> guarantee no-one else changes the code to use MAX() again.
> Furthermore, it guarantees that MAX_CONST is *really* called with
> constant arguments.

If that is what it takes, go ahead.

Let it be known though for all future: I think LLVM is stupid here.

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list