[CDRIVER-702] Warnings due to GCC extensions (-wpedantic) Created: 10/Jun/15  Updated: 29/Jan/18  Resolved: 29/Jan/18

Status: Closed
Project: C Driver
Component/s: None
Affects Version/s: 1.1.7
Fix Version/s: 1.2.4

Type: New Feature Priority: Minor - P4
Reporter: Jeroen Ooms [X] Assignee: A. Jesse Jiryu Davis
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to CDRIVER-1560 ISO C warnings (GNU extensions) Closed
related to CDRIVER-1563 Compiler warning maybe-uninitialized Closed
is related to CDRIVER-669 Turn compiler warnings into errs on E... Closed
is related to CDRIVER-2125 Warnings generated by headers when co... Closed
Epic Link: mongoc-toolchain

 Description   

The 1.1.7 release of mongoc and libbson introduced some new portability problems due to the use of GNU extensions. These can easily be reproduced by compiling with -pedantic.

gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I. -Iyajl -Ibson -Imongoc -include apple.h -include mlfeatures.h -I/opt/csw/include -DBSON_COMPILATION -DMONGOC_COMPILATION      -fpic  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -O3 -Wall -pipe -pedantic -std=gnu99 -c bson/bson-context.c -o bson/bson-context.o
In file included from bson/bson-context.c:32:0:
bson/bson-context-private.h:31:4: warning: type of bit-field ‘flags’ is a GCC extension [-Wpedantic]
    bson_context_flags_t flags : 7;
    ^
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I. -Iyajl -Ibson -Imongoc -include apple.h -include mlfeatures.h -I/opt/csw/include -DBSON_COMPILATION -DMONGOC_COMPILATION      -fpic  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -O3 -Wall -pipe -pedantic -std=gnu99 -c bson/bson-iso8601.c -o bson/bson-iso8601.o
bson/bson-iso8601.c: In function ‘_bson_iso8601_date_parse’:
bson/bson-iso8601.c:227:30: warning: ‘sec_ptr’ may be used uninitialized in this function [-Wmaybe-uninitialized]
    if (sec_len && !parse_num (sec_ptr, sec_len, 2, 0, 60, &sec)) {
                              ^
bson/bson-iso8601.c:273:31: warning: ‘millis_ptr’ may be used uninitialized in this function [-Wmaybe-uninitialized]
          millis += (millis_ptr[millis_len - i] - '0') * magnitude;
                               ^
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I. -Iyajl -Ibson -Imongoc -include apple.h -include mlfeatures.h -I/opt/csw/include -DBSON_COMPILATION -DMONGOC_COMPILATION      -fpic  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -O3 -Wall -pipe -pedantic -std=gnu99 -c bson/bson-oid.c -o bson/bson-oid.o
In file included from bson/bson-oid.c:24:0:
bson/bson-context-private.h:31:4: warning: type of bit-field ‘flags’ is a GCC extension [-Wpedantic]
    bson_context_flags_t flags : 7;
    ^
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I. -Iyajl -Ibson -Imongoc -include apple.h -include mlfeatures.h -I/opt/csw/include -DBSON_COMPILATION -DMONGOC_COMPILATION      -fpic  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -O3 -Wall -pipe -pedantic -std=gnu99 -c mongoc/mongoc-bulk-operation.c -o mongoc/mongoc-bulk-operation.o
In file included from mongoc/mongoc-bulk-operation-private.h:26:0,
                 from mongoc/mongoc-bulk-operation.c:19:
mongoc/mongoc-write-command-private.h:46:10: warning: type of bit-field ‘ordered’ is a GCC extension [-Wpedantic]
          uint8_t   ordered : 1;
          ^
mongoc/mongoc-write-command-private.h:47:10: warning: type of bit-field ‘multi’ is a GCC extension [-Wpedantic]
          uint8_t   multi : 1;
          ^
mongoc/mongoc-write-command-private.h:50:10: warning: type of bit-field ‘ordered’ is a GCC extension [-Wpedantic]
          uint8_t   ordered : 1;
          ^
mongoc/mongoc-write-command-private.h:51:10: warning: type of bit-field ‘allow_bulk_op_insert’ is a GCC extension [-Wpedantic]
          uint8_t   allow_bulk_op_insert : 1;
          ^
mongoc/mongoc-write-command-private.h:54:10: warning: type of bit-field ‘ordered’ is a GCC extension [-Wpedantic]
          uint8_t   ordered : 1;
          ^
-DBSON_COMPILATION -DMONGOC_COMPILATION      -fpic  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -O3 -Wall -pipe -pedantic -std=gnu99 -c mongoc/mongoc-collection.c -o mongoc/mongoc-collection.o
In file included from mongoc/mongoc-bulk-operation-private.h:26:0,
                 from mongoc/mongoc-collection.c:22:
mongoc/mongoc-write-command-private.h:46:10: warning: type of bit-field ‘ordered’ is a GCC extension [-Wpedantic]
          uint8_t   ordered : 1;
          ^
mongoc/mongoc-write-command-private.h:47:10: warning: type of bit-field ‘multi’ is a GCC extension [-Wpedantic]
          uint8_t   multi : 1;
          ^
mongoc/mongoc-write-command-private.h:50:10: warning: type of bit-field ‘ordered’ is a GCC extension [-Wpedantic]
          uint8_t   ordered : 1;
          ^
mongoc/mongoc-write-command-private.h:51:10: warning: type of bit-field ‘allow_bulk_op_insert’ is a GCC extension [-Wpedantic]
          uint8_t   allow_bulk_op_insert : 1;
          ^
mongoc/mongoc-write-command-private.h:54:10: warning: type of bit-field ‘ordered’ is a GCC extension [-Wpedantic]
          uint8_t   ordered : 1;
          ^
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I. -Iyajl -Ibson -Imongoc -include apple.h -include mlfeatures.h -I/opt/csw/include -DBSON_COMPILATION -DMONGOC_COMPILATION      -fpic  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -O3 -Wall -pipe -pedantic -std=gnu99 -c mongoc/mongoc-gridfs.c -o mongoc/mongoc-gridfs.o
mongoc/mongoc-gridfs.c: In function ‘_mongoc_gridfs_new’:
mongoc/mongoc-gridfs.c:110:16: warning: variable ‘prefix_len’ set but not used [-Wunused-but-set-variable]
       uint32_t prefix_len;
                ^
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I. -Iyajl -Ibson -Imongoc -include apple.h -include mlfeatures.h -I/opt/csw/include -DBSON_COMPILATION -DMONGOC_COMPILATION      -fpic  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -O3 -Wall -pipe -pedantic -std=gnu99 -c mongoc/mongoc-write-command.c -o mongoc/mongoc-write-command.o
In file included from mongoc/mongoc-write-command.c:21:0:
mongoc/mongoc-write-command-private.h:46:10: warning: type of bit-field ‘ordered’ is a GCC extension [-Wpedantic]
          uint8_t   ordered : 1;
          ^
mongoc/mongoc-write-command-private.h:47:10: warning: type of bit-field ‘multi’ is a GCC extension [-Wpedantic]
          uint8_t   multi : 1;
          ^
mongoc/mongoc-write-command-private.h:50:10: warning: type of bit-field ‘ordered’ is a GCC extension [-Wpedantic]
          uint8_t   ordered : 1;
          ^
mongoc/mongoc-write-command-private.h:51:10: warning: type of bit-field ‘allow_bulk_op_insert’ is a GCC extension [-Wpedantic]
          uint8_t   allow_bulk_op_insert : 1;
          ^
mongoc/mongoc-write-command-private.h:54:10: warning: type of bit-field ‘ordered’ is a GCC extension [-Wpedantic]
          uint8_t   ordered : 1;
          ^



 Comments   
Comment by Hannes Magnusson [ 18/Oct/16 ]

Marking this as a new feature.

Currently we don't support building with -pedantic and expect certain "gcc extensions" (which is supported by all compilers we support).

Comment by A. Jesse Jiryu Davis [ 14/Jun/15 ]

Thanks for reporting this Jeroen.

Generated at Wed Feb 07 21:10:22 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.