Skip to content

Conversation

@hebasto
Copy link
Member

@hebasto hebasto commented Dec 17, 2025

On some non-POSIX platforms, Clang emits -Wmissing-braces warnings for the IN6ADDR_ANY_INIT and IN6ADDR_LOOPBACK_INIT macros. For example, on OpenIndiana / illumos:

$ uname -srv
SunOS 5.11 illumos-325e0fc8bb
$ clang --version
clang version 21.1.7 (https://github.com/OpenIndiana/oi-userland.git 36a81bf5e5d307d4e85893422600678d46328010)
Target: x86_64-pc-solaris2.11
Thread model: posix
InstalledDir: /usr/clang/21/bin
$ cmake -B build -DCMAKE_GENERATOR=Ninja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DENABLE_IPC=OFF -DAPPEND_CXXFLAGS='-Wno-unused-command-line-argument'
$ cmake --build build
[284/573] Building CXX object src/CMakeFiles/bitcoin_node.dir/net.cpp.o
/export/home/hebasto/dev/bitcoin/src/net.cpp:3309:42: warning: suggest braces around initialization of subobject [-Wmissing-braces]
 3309 |         const CService ipv6_any{in6_addr(IN6ADDR_ANY_INIT), GetListenPort()}; // ::
      |                                          ^~~~~~~~~~~~~~~~
/usr/include/netinet/in.h:479:32: note: expanded from macro 'IN6ADDR_ANY_INIT'
  479 | #define IN6ADDR_ANY_INIT            {   0, 0, 0, 0,     \
      |                                         ^~~~~~~~~~~~~~~~~
  480 |                                         0, 0, 0, 0,     \
      |                                         ~~~~~~~~~~~~~~~~~
  481 |                                         0, 0, 0, 0,     \
      |                                         ~~~~~~~~~~~~~~~~~
  482 |                                         0, 0, 0, 0 }
      |                                         ~~~~~~~~~~
1 warning generated.
[467/573] Building CXX object src/test/CMakeFiles/test_bitcoin.dir/i2p_tests.cpp.o
/export/home/hebasto/dev/bitcoin/src/test/i2p_tests.cpp:116:34: warning: suggest braces around initialization of subobject [-Wmissing-braces]
  116 |     const CService addr{in6_addr(IN6ADDR_LOOPBACK_INIT), /*port=*/7656};
      |                                  ^~~~~~~~~~~~~~~~~~~~~
/usr/include/netinet/in.h:484:37: note: expanded from macro 'IN6ADDR_LOOPBACK_INIT'
  484 | #define IN6ADDR_LOOPBACK_INIT       {   0, 0, 0, 0,     \
      |                                         ^~~~~~~~~~~~~~~~~
  485 |                                         0, 0, 0, 0,     \
      |                                         ~~~~~~~~~~~~~~~~~
  486 |                                         0, 0, 0, 0,     \
      |                                         ~~~~~~~~~~~~~~~~~
  487 |                                         0, 0, 0, 0x1U }
      |                                         ~~~~~~~~~~~~~
/export/home/hebasto/dev/bitcoin/src/test/i2p_tests.cpp:159:38: warning: suggest braces around initialization of subobject [-Wmissing-braces]
  159 |         const CService addr{in6_addr(IN6ADDR_LOOPBACK_INIT), /*port=*/7656};
      |                                      ^~~~~~~~~~~~~~~~~~~~~
/usr/include/netinet/in.h:484:37: note: expanded from macro 'IN6ADDR_LOOPBACK_INIT'
  484 | #define IN6ADDR_LOOPBACK_INIT       {   0, 0, 0, 0,     \
      |                                         ^~~~~~~~~~~~~~~~~
  485 |                                         0, 0, 0, 0,     \
      |                                         ~~~~~~~~~~~~~~~~~
  486 |                                         0, 0, 0, 0,     \
      |                                         ~~~~~~~~~~~~~~~~~
  487 |                                         0, 0, 0, 0x1U }
      |                                         ~~~~~~~~~~~~~
2 warnings generated.
[483/573] Building CXX object src/test/CMakeFiles/test_bitcoin.dir/netbase_tests.cpp.o
/export/home/hebasto/dev/bitcoin/src/test/netbase_tests.cpp:505:36: warning: suggest braces around initialization of subobject [-Wmissing-braces]
  505 |         CService(CNetAddr(in6_addr(IN6ADDR_LOOPBACK_INIT)), 0 /* port */),
      |                                    ^~~~~~~~~~~~~~~~~~~~~
/usr/include/netinet/in.h:484:37: note: expanded from macro 'IN6ADDR_LOOPBACK_INIT'
  484 | #define IN6ADDR_LOOPBACK_INIT       {   0, 0, 0, 0,     \
      |                                         ^~~~~~~~~~~~~~~~~
  485 |                                         0, 0, 0, 0,     \
      |                                         ~~~~~~~~~~~~~~~~~
  486 |                                         0, 0, 0, 0,     \
      |                                         ~~~~~~~~~~~~~~~~~
  487 |                                         0, 0, 0, 0x1U }
      |                                         ~~~~~~~~~~~~~
/export/home/hebasto/dev/bitcoin/src/test/netbase_tests.cpp:510:36: warning: suggest braces around initialization of subobject [-Wmissing-braces]
  510 |         CService(CNetAddr(in6_addr(IN6ADDR_LOOPBACK_INIT)), 0x00f1 /* port */),
      |                                    ^~~~~~~~~~~~~~~~~~~~~
/usr/include/netinet/in.h:484:37: note: expanded from macro 'IN6ADDR_LOOPBACK_INIT'
  484 | #define IN6ADDR_LOOPBACK_INIT       {   0, 0, 0, 0,     \
      |                                         ^~~~~~~~~~~~~~~~~
  485 |                                         0, 0, 0, 0,     \
      |                                         ~~~~~~~~~~~~~~~~~
  486 |                                         0, 0, 0, 0,     \
      |                                         ~~~~~~~~~~~~~~~~~
  487 |                                         0, 0, 0, 0x1U }
      |                                         ~~~~~~~~~~~~~
/export/home/hebasto/dev/bitcoin/src/test/netbase_tests.cpp:515:36: warning: suggest braces around initialization of subobject [-Wmissing-braces]
  515 |         CService(CNetAddr(in6_addr(IN6ADDR_LOOPBACK_INIT)), 0xf1f2 /* port */),
      |                                    ^~~~~~~~~~~~~~~~~~~~~
/usr/include/netinet/in.h:484:37: note: expanded from macro 'IN6ADDR_LOOPBACK_INIT'
  484 | #define IN6ADDR_LOOPBACK_INIT       {   0, 0, 0, 0,     \
      |                                         ^~~~~~~~~~~~~~~~~
  485 |                                         0, 0, 0, 0,     \
      |                                         ~~~~~~~~~~~~~~~~~
  486 |                                         0, 0, 0, 0,     \
      |                                         ~~~~~~~~~~~~~~~~~
  487 |                                         0, 0, 0, 0x1U }
      |                                         ~~~~~~~~~~~~~
3 warnings generated.
[573/573] Linking CXX executable bin/test_bitcoin

The same issue is observed on Windows. For further details, see #31507.

@DrahtBot DrahtBot added the P2P label Dec 17, 2025
@DrahtBot
Copy link
Contributor

DrahtBot commented Dec 17, 2025

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage & Benchmarks

For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/34090.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK bensig

If your review is incorrectly listed, please copy-paste <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #31507 (build: Use clang-cl to build on Windows natively by hebasto)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@fanquake
Copy link
Member

https://github.com/bitcoin/bitcoin/actions/runs/20307057596/job/58327346295?pr=34090#step:11:495:

   net_processing.cpp
  netgroup.cpp
D:\a\bitcoin\bitcoin\src\net.cpp(3309,41): error C2440: '<function-style-cast>': cannot convert from 'initializer list' to 'in6_addr' [D:\a\bitcoin\bitcoin\build\src\bitcoin_node.vcxproj]
      D:\a\bitcoin\bitcoin\src\net.cpp(3309,41):
      'in6_addr::in6_addr': no overloaded function could convert all the argument types
          C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\shared\in6addr.h(30,1):
          could be 'in6_addr::in6_addr(in6_addr &&)'
              D:\a\bitcoin\bitcoin\src\net.cpp(3309,41):
              'in6_addr::in6_addr(in6_addr &&)': cannot convert argument 1 from 'initializer list' to 'in6_addr &&'
                  D:\a\bitcoin\bitcoin\src\net.cpp(3309,42):
                  Reason: cannot convert from 'initializer list' to 'in6_addr'
                  D:\a\bitcoin\bitcoin\src\net.cpp(3309,42):
                  Invalid aggregate initialization
                      D:\a\bitcoin\bitcoin\src\net.cpp(3309,42):
                      'initializing': cannot convert from 'initializer list' to 'UCHAR'
                          D:\a\bitcoin\bitcoin\src\net.cpp(3309,42):
                          Too many braces around initializer for 'UCHAR'
          C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\shared\in6addr.h(30,1):
          or       'in6_addr::in6_addr(const in6_addr &)'
              D:\a\bitcoin\bitcoin\src\net.cpp(3309,41):
              'in6_addr::in6_addr(const in6_addr &)': cannot convert argument 1 from 'initializer list' to 'const in6_addr &'
                  D:\a\bitcoin\bitcoin\src\net.cpp(3309,42):
                  Reason: cannot convert from 'initializer list' to 'const in6_addr'
                  D:\a\bitcoin\bitcoin\src\net.cpp(3309,42):
                  Invalid aggregate initialization
                      D:\a\bitcoin\bitcoin\src\net.cpp(3309,42):
                      'initializing': cannot convert from 'initializer list' to 'UCHAR'
                          D:\a\bitcoin\bitcoin\src\net.cpp(3309,42):
                          Too many braces around initializer for 'UCHAR'
          D:\a\bitcoin\bitcoin\src\net.cpp(3309,41):
          while trying to match the argument list '(initializer list)'

@hebasto hebasto force-pushed the 251217-in6addr-compat branch 2 times, most recently from b27a944 to d307567 Compare December 17, 2025 16:23
@hebasto hebasto force-pushed the 251217-in6addr-compat branch from d307567 to f46e3ec Compare December 17, 2025 16:54
@hebasto
Copy link
Member Author

hebasto commented Dec 17, 2025

@bensig
Copy link
Contributor

bensig commented Jan 4, 2026

ACK f46e3ec

Builds clean, netbase_tests and i2p_tests pass.
Clean fix using compat layer for platform-specific brace style in IN6ADDR_*_INIT macros.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants