Re: bind() to ::1 fails with EADDRNOTAVAIL / clang vs gcc

2021-11-23 Thread Jan Schaumann via freebsd-net
Jan Schaumann via freebsd-net wrote: > Konstantin Belousov wrote: > > On Tue, Nov 23, 2021 at 09:08:39PM -0500, Jan Schaumann via freebsd-net > > wrote: > > > > - Why does _any_ of those fail? > > > - Why does a.c succeed when compiled with clang, but > > > b.c does not? > > Most likely becau

Re: bind() to ::1 fails with EADDRNOTAVAIL / clang vs gcc

2021-11-23 Thread Jan Schaumann via freebsd-net
Konstantin Belousov wrote: > On Tue, Nov 23, 2021 at 09:08:39PM -0500, Jan Schaumann via freebsd-net wrote: > > - Why does _any_ of those fail? > > - Why does a.c succeed when compiled with clang, but > > b.c does not? > Most likely because you did not fully initialized *sin. > Really it is UB

Re: bind() to ::1 fails with EADDRNOTAVAIL / clang vs gcc

2021-11-23 Thread Konstantin Belousov
On Tue, Nov 23, 2021 at 09:08:39PM -0500, Jan Schaumann via freebsd-net wrote: > Hello, > > I'm observing the following strange behavior, where > trying to bind(2) a socket on "::1" fails with > EADDRNOTAVAIL, but binding in6addr_any will succeed > (and then yield a bound ::1). What's more, the >

Re: bind() to ::1 fails with EADDRNOTAVAIL / clang vs gcc

2021-11-23 Thread Jan Schaumann via freebsd-net
Jan Schaumann via freebsd-net wrote: > Compiling either with gcc version 10.3.0 fails. Sorry, this is misleading. I meant to say: Compiling either with gcc version 10.3.0 yields a program that fails to bind(2). Compilation itself succeeds just fine. -Jan

bind() to ::1 fails with EADDRNOTAVAIL / clang vs gcc

2021-11-23 Thread Jan Schaumann via freebsd-net
Hello, I'm observing the following strange behavior, where trying to bind(2) a socket on "::1" fails with EADDRNOTAVAIL, but binding in6addr_any will succeed (and then yield a bound ::1). What's more, the behavior is inconsistent depending on the compiler used. Here's my sample program a.c: ---