sustrik / libdill

Structured concurrency in C
MIT License
1.69k stars 155 forks source link

Compilation fails with arm-linux-musleabi-gcc (GCC) 9.1.0 #191

Open eerimoq opened 5 years ago

eerimoq commented 5 years ago

Failure:

$ arm-linux-musleabi-gcc -I. -c ipaddr.c -o libdill_la-ipaddr.o
In file included from ipaddr.c:44:
ipaddr.c: In function 'dill_ipaddr_remotes':
dns/dns.h:1009:24: error: lvalue required as unary '&' operand
 1009 | #define dns_opts(...) (&dns_quietinit((struct dns_options)DNS_OPTS_INIT(__VA_ARGS__)))
      |                        ^
ipaddr.c:335:47: note: in expansion of macro 'dns_opts'
  335 |         dill_dns_hosts, dill_dns_hints, NULL, dns_opts(), &rc);
      |                                               ^~~~~~~~
$ gcc -I. -c ipaddr.c -o libdill_la-ipaddr.o
$

Compiler versions:

$ arm-linux-musleabi-gcc --version
arm-linux-musleabi-gcc (GCC) 9.1.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ gcc --version
gcc (Ubuntu 8.3.0-6ubuntu1) 8.3.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$

I've only tested with these two compilers.

tmlbl commented 5 years ago

I am also seeing this error with gcc on Clear Linux

$ gcc --version
gcc (Clear Linux OS for Intel Architecture) 9.1.1 20190529 gcc-9-branch@271737

It can be reproduced exactly as above

sustrik commented 5 years ago

Unfortunately, this looks like a bug in dns.c. The project can be found here: https://github.com/wahern/dns

tmlbl commented 5 years ago

Yes, unfortunately it seems to be pretty widespread throughout the library, and I don't know enough about C macros to fix it :(

adel-mamin commented 5 years ago

@eerimoq @tmlbl I added https://github.com/sustrik/libdill/pull/197 to address this issue. Please take a look.

DataPacRat commented 5 years ago

Compilation also fails at the same point when using: gcc (GCC) 9.2.1 20190827 (Red Hat 9.2.1-1)

ziotom78 commented 4 years ago

I confirm the same issue on my Linux Manjaro computer, running GCC 9.2.0:

$ gcc --version
gcc (GCC) 9.2.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ uname -a
Linux servername 5.4.13-3-MANJARO #1 SMP PREEMPT Mon Jan 20 18:17:25 UTC 2020 x86_64 GNU/Linux

$ lsb_release -a
LSB Version:    n/a
Distributor ID: ManjaroLinux
Description:    Manjaro Linux
Release:    18.1.5
Codename:   Juhraya
sug0 commented 4 years ago

It builds with clang, for people who come here with the same issue. Just do a make CC=clang and you're good.

ilitzroth commented 3 years ago

with clang --version Ubuntu clang version 11.0.0-++20200929060912+dda0a1867cc-1~exp1~20200929162359.110 Target: x86_64-pc-linux-gnu Thread model: posix InstalledDir: /usr/bin

make CC=clang [ 1%] Building C object CMakeFiles/dill.dir/dns/dns.c.o In file included from /home/immanuel/workspace/libdill/dns/dns.c:94: /home/immanuel/workspace/libdill/dns/dns.c: In function 'dns_p_merge': /home/immanuel/workspace/libdill/dns/dns.h:499:16: error: lvalue required as unary '&' operand 499 | dns_rr_i_init(&dns_quietinit((struct dns_rr_i){ 0, __VA_ARGS__ }), (P)) ...

sug0 commented 3 years ago

@ilitzroth It worked for me:

clang version 11.0.0
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /bin

Perhaps try these steps:

git clone https://github.com/sustrik/libdill
cd libdill
mkdir build
cd build
CC=clang cmake ..
make
laoshaw commented 2 years ago

same issue here, why gcc-9/10/11 are all failing?