View Issue Details

IDProjectCategoryView StatusLast Update
0005302libmicrohttpdcompliancepublic2018-03-23 22:52
Reportersilvioprog Assigned ToChristian Grothoff  
PrioritynoneSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product VersionGit master 
Fixed in Version0.9.59 
Summary0005302: MHD does not compile when the compiler is configured to be more strict (gcc/clang)
DescriptionHello.

From my build folder, I've configured the environment using some custom options as below:

../configure --enable-static=yes --enable-shared=no --enable-https=no --enable-asserts=no --enable-coverage=no --disable-httpupgrade --disable-doc --disable-examples --disable-curl


after, I've tried to compile the library passing some gcc/clang options I use in my project:

make CFLAGS="-Wall -Werror -Wextra -Wdeclaration-after-statement -Wstrict-prototypes -Wmissing-declarations -Wredundant-decls -Wnested-externs -Winline -Wpadded"


however, I've got the following warnings (converted to errors by -Werror):

[snip]
libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../../../src/microhttpd -I../.. -I../../../src/include -I../../../src/microhttpd -DBUILDING_MHD_LIB=1 -fvisibility=hidden -pthread -Wall -Werror -Wextra -Wdeclaration-after-statement -Wstrict-prototypes -Wmissing-declarations -Wredundant-decls -Wnested-externs -Winline -Wpadded -MT libmicrohttpd_la-connection.lo -MD -MP -MF .deps/libmicrohttpd_la-connection.Tpo -c ../../../src/microhttpd/connection.c -o libmicrohttpd_la-connection.o
In file included from ../../../src/microhttpd/internal.h:32:0,
                 from ../../../src/microhttpd/connection.c:28:
../../../src/include/microhttpd.h:1506:12: error: padding struct to align ‘value’ [-Werror=padded]
   intptr_t value;
            ^
In file included from ../../../src/microhttpd/connection.c:28:0:
../../../src/microhttpd/internal.h:242:1: error: padding struct size to alignment boundary [-Werror=padded]
 };
 ^
../../../src/microhttpd/internal.h:282:1: error: padding struct size to alignment boundary [-Werror=padded]
 };
 ^
../../../src/microhttpd/internal.h:385:1: error: padding struct size to alignment boundary [-Werror=padded]
 };
 ^
../../../src/microhttpd/internal.h:718:9: error: padding struct to align ‘read_buffer’ [-Werror=padded]
   char *read_buffer;
         ^
../../../src/microhttpd/internal.h:816:10: error: padding struct to align ‘continue_message_write_offset’ [-Werror=padded]
   size_t continue_message_write_offset;
          ^
../../../src/microhttpd/internal.h:827:10: error: padding struct to align ‘last_activity’ [-Werror=padded]
   time_t last_activity;
          ^
../../../src/microhttpd/internal.h:852:14: error: padding struct to align ‘socket_fd’ [-Werror=padded]
   MHD_socket socket_fd;
              ^
../../../src/microhttpd/internal.h:888:23: error: padding struct to align ‘epoll_state’ [-Werror=padded]
   enum MHD_EpollState epoll_state;
                       ^
../../../src/microhttpd/internal.h:922:12: error: padding struct to align ‘current_chunk_size’ [-Werror=padded]
   uint64_t current_chunk_size;
            ^
../../../src/microhttpd/internal.h:987:7: error: padding struct to align ‘suspended_dummy’ [-Werror=padded]
   int suspended_dummy;
       ^
../../../src/microhttpd/internal.h:993:1: error: padding struct size to alignment boundary [-Werror=padded]
 };
 ^
../../../src/microhttpd/internal.h:1440:25: error: padding struct to align ‘pid’ [-Werror=padded]
   MHD_thread_handle_ID_ pid;
                         ^
../../../src/microhttpd/internal.h:1500:19: error: padding struct to align ‘itc’ [-Werror=padded]
   struct MHD_itc_ itc;
                   ^
../../../src/microhttpd/internal.h:1542:16: error: padding struct to align ‘connections’ [-Werror=padded]
   unsigned int connections;
                ^
../../../src/microhttpd/internal.h:1553:10: error: padding struct to align ‘connection_timeout’ [-Werror=padded]
   time_t connection_timeout;
          ^
../../../src/microhttpd/internal.h:1574:7: error: padding struct to align ‘strict_for_client’ [-Werror=padded]
   int strict_for_client;
       ^
../../../src/microhttpd/internal.h:1694:1: error: padding struct size to alignment boundary [-Werror=padded]
 };
 ^
../../../src/microhttpd/connection.c: In function ‘socket_start_extra_buffering’:
../../../src/microhttpd/connection.c:500:3: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
   const MHD_SCKT_OPT_BOOL_ on_val = 1;
   ^
cc1: all warnings being treated as errors
Makefile:1196: recipe for target 'libmicrohttpd_la-connection.lo' failed
make[3]: *** [libmicrohttpd_la-connection.lo] Error 1
make[3]: Leaving directory '/home/silvioprog/dev/git/libmicrohttpd/build/src/microhttpd'
Makefile:445: recipe for target 'all-recursive' failed
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory '/home/silvioprog/dev/git/libmicrohttpd/build/src'
Makefile:571: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/silvioprog/dev/git/libmicrohttpd/build'
Makefile:478: recipe for target 'all' failed
make: *** [all] Error 2
Additional InformationI fixed it in my local copy in a draft, however I'm not sure about its ABI compatibility, so I'm going to refactore my changes and attach a patch showing them.
TagsNo tags attached.

Activities

Christian Grothoff

2018-03-23 22:20

manager   ~0012892

We will not fix padding warnings. Those are very silly, and "fixing" them will just cause other problems. Do not use those compiler settings.

silvioprog

2018-03-23 22:43

developer   ~0012895

Sorry for reopening, but there is another error in the list:

[snip]
../../../src/microhttpd/connection.c: In function ‘socket_start_extra_buffering’:
../../../src/microhttpd/connection.c:500:3: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
   const MHD_SCKT_OPT_BOOL_ on_val = 1;
   ^


IMHO it should be fixed.

The errors regarding padding should be fixed just using gcc/clang attributes, so any project that uses MHD could use any compiler preferences. WDYT?

Christian Grothoff

2018-03-23 22:52

manager   ~0012896

I am against cluttering code against absolutely stupid compiler warnings/settings.

As for the ISO c90 warning, 090ee9e6..62121567 fixes it.

Issue History

Date Modified Username Field Change
2018-03-23 16:30 silvioprog New Issue
2018-03-23 22:20 Christian Grothoff Note Added: 0012892
2018-03-23 22:20 Christian Grothoff Assigned To => Christian Grothoff
2018-03-23 22:20 Christian Grothoff Priority normal => none
2018-03-23 22:20 Christian Grothoff Reproducibility have not tried => always
2018-03-23 22:20 Christian Grothoff Status new => closed
2018-03-23 22:20 Christian Grothoff Resolution open => won't fix
2018-03-23 22:20 Christian Grothoff Category other => compliance
2018-03-23 22:20 Christian Grothoff Fixed in Version => 0.9.59
2018-03-23 22:20 Christian Grothoff Target Version Git master =>
2018-03-23 22:43 silvioprog Assigned To Christian Grothoff =>
2018-03-23 22:43 silvioprog Status closed => feedback
2018-03-23 22:43 silvioprog Resolution won't fix => reopened
2018-03-23 22:43 silvioprog Note Added: 0012895
2018-03-23 22:52 Christian Grothoff Note Added: 0012896
2018-03-23 22:52 Christian Grothoff Assigned To => Christian Grothoff
2018-03-23 22:52 Christian Grothoff Status feedback => closed
2018-03-23 22:52 Christian Grothoff Resolution reopened => fixed