Bug 1067426 - mingw IPv6 compilation fails under -Werror=missing-braces
Summary: mingw IPv6 compilation fails under -Werror=missing-braces
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: mingw-headers
Version: 20
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Erik van Pienbroek
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-02-20 12:53 UTC by Eric Blake
Modified: 2014-05-30 13:46 UTC (History)
6 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2014-05-30 13:46:31 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Eric Blake 2014-02-20 12:53:26 UTC
Description of problem:
Mingw's definition of struct in6_addr requires multiple levels of {} to silence gcc's -Wmissing-braces; however, the definition in <ws2tcpip.h> lacks these.  It would also be nice if mingw could provide the standardized <netinet/in.h> as the POSIX name for getting at these macros.

Version-Release number of selected component (if applicable):
mingw32-headers-3.1.0-1.fc20.noarch

How reproducible:
100%

Steps to Reproduce:
1. $ cat a.c
#ifdef __linux__
#include <netinet/in.h>
#else
#include <ws2tcpip.h>
#endif
int foo(void) {
  struct in6_addr a = IN6ADDR_ANY_INIT;
  struct in6_addr b = IN6ADDR_LOOPBACK_INIT;
  return IN6_IS_ADDR_UNSPECIFIED(&a) + IN6_IS_ADDR_LOOPBACK(&b);
}

2. $ gcc -c -o a.o -Wall -Wmissing-braces a.c

3. $ i686-w64-mingw32-gcc -c -o a.o -Wall -Wmissing-braces a.c

Actual results:
2 is silent, 3 spews:

a.c: In function 'foo':
a.c:7:10: warning: missing braces around initializer [-Wmissing-braces]
   struct in6_addr a = IN6ADDR_ANY_INIT;
          ^
a.c:7:10: warning: (near initialization for 'a.u') [-Wmissing-braces]
a.c:8:10: warning: missing braces around initializer [-Wmissing-braces]
   struct in6_addr b = IN6ADDR_LOOPBACK_INIT;
          ^
a.c:8:10: warning: (near initialization for 'b.u') [-Wmissing-braces]


Expected results:
Just as glibc's definition is silent, mingw should add enough {} to allow silent compilation.

Additional info:
Libvirt has had to workaround the problem by using initialization by struct copy, rather than the standardized IP6ADDR_ANY_INIT, because it compiles with -Werror -Wmissing-braces:
http://libvirt.org/git/?p=libvirt.git;a=commitdiff;h=057d26b2ac05dc3d2

Comment 1 Erik van Pienbroek 2014-02-20 18:15:26 UTC
@Kai Tietz: Could you take a look at this? This sounds like material which should be resolved in upstream mingw-w64

Comment 2 Erik van Pienbroek 2014-05-30 12:18:24 UTC
I managed to get this issue fixed upstream:
https://sourceforge.net/p/mingw-w64/mingw-w64/ci/b8e8160da0648fc0406b028a2bff0938d9b9175e/

The latest mingw-headers in rawhide and EPEL7 contains this fix (mingw-headers-3.1.999-0.10.trunk.gitb8e816.20140530.fc21).
Do you want the fix to be backported to other Fedora branches as well?

Comment 3 Eric Blake 2014-05-30 13:07:18 UTC
(In reply to Erik van Pienbroek from comment #2)
> Do you want the fix to be backported to other Fedora branches as well?

At this point, libvirt has already installed a workaround and does mingw cross builds just fine on current F20 headers, so there's no urgent need for a backport. Up to you if you want to just leave the bug present in older releases and require people to upgrade to benefit from the newer header.

Comment 4 Erik van Pienbroek 2014-05-30 13:46:31 UTC
Okay, then I'll leave the f19 and f20 branches 'as is' for now as there are no known other mingw packages which fail to build because of this bug.


Note You need to log in before you can comment on or make changes to this bug.