[CDRIVER-2374] Non C99 GNU extension Created: 14/Nov/17  Updated: 28/Oct/23  Resolved: 19/Nov/17

Status: Closed
Project: C Driver
Component/s: None
Affects Version/s: 1.8.1
Fix Version/s: 1.9.0

Type: Bug Priority: Major - P3
Reporter: Jeroen Ooms [X] Assignee: A. Jesse Jiryu Davis
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

We need pure C99 for the R bindings (no GNU extensions).

-I/usr/local/include   -fPIC  -Wall -pedantic -c mongoc/mongoc-cluster.c -o mongoc/mongoc-cluster.o
mongoc/mongoc-client.c:2549:4: warning: void function '_mongoc_client_push_server_session' should not return void expression [-Wpedantic]
   return _mongoc_topology_push_server_session (client->topology,
   ^      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
mongoc/mongoc-cluster.c:124:31: warning: arithmetic on a pointer to void is a GNU extension [-Wpointer-arith]
              iov[n].iov_base + difference,
              ~~~~~~~~~~~~~~~ ^
/usr/include/secure/_string.h:62:33: note: expanded from macro 'memcpy'
                __builtin___memcpy_chk (dest, __VA_ARGS__, __darwin_obsz0 (dest))

To fix simply cast the pointer to a typed pointer (e.g. int*) before incrementing it.



 Comments   
Comment by Githook User [ 04/Jan/18 ]

Author:

{'name': 'A. Jesse Jiryu Davis', 'username': 'ajdavis', 'email': 'jesse@mongodb.com'}

Message: CDRIVER-2374 fix C99 pedantic warnings, part 3
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/000cea922c0016921e743dbabf2d01c85191f2bf

Comment by Githook User [ 19/Nov/17 ]

Author:

{'name': 'A. Jesse Jiryu Davis', 'username': 'ajdavis', 'email': 'jesse@mongodb.com'}

Message: CDRIVER-2374 fix C99 pedantic warnings, part 2

Decided not to test clang on Ubuntu with -std=c99 -pedantic after all.
The goal is to make R libraries like mongolite compile cleanly with
MinGW on Windows with -std=c99 -pedantic. I seem to have achieved that
and it's tested in Evergreen.
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/b40842208d426b6984bc943c1922d4d64ce951a5

Comment by Githook User [ 19/Nov/17 ]

Author:

{'name': 'A. Jesse Jiryu Davis', 'username': 'ajdavis', 'email': 'jesse@mongodb.com'}

Message: CDRIVER-2374 fix C99 pedantic warnings
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/b06d444d3e385f22260333f55cd5f1bd2c4328b8

Comment by Githook User [ 19/Nov/17 ]

Author:

{'name': 'A. Jesse Jiryu Davis', 'username': 'ajdavis', 'email': 'jesse@mongodb.com'}

Message: CDRIVER-2374 test "pedantic" cflag
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/3fd627143085fa2c5015eda6c43c3ec592362244

Comment by Githook User [ 19/Nov/17 ]

Author:

{'name': 'A. Jesse Jiryu Davis', 'username': 'ajdavis', 'email': 'jesse@mongodb.com'}

Message: CDRIVER-2374 fix C99 pedantic warning
Branch: master
https://github.com/mongodb/libbson/commit/b908d31737ef15f0317240d7c7652aad21532bfe

Comment by Jeroen Ooms [X] [ 18/Nov/17 ]

Hmm I'm not seeing that error on clang. The gcc manual page says:

Allowable bit-field types other than _Bool, signed int, and unsigned int (C99 6.7.2.1).
No other types are permitted in strictly conforming mode.

Comment by A. Jesse Jiryu Davis [ 18/Nov/17 ]

Fixed, thanks Jeroen.

We regularly test compiling the driver with GCC and "-std=c99", but not with "-std=c99 -pedantic". I tried it just now and see a new error that I don't know how to fix:

In file included from src/bson/bson-context.c:28:0:
src/bson/bson-context-private.h:30:4: error: type of bit-field 'flags' is a GCC extension [-Werror=pedantic]
    bson_context_flags_t flags : 7;
    ^

This is GCC 4.8 on Ubuntu. I guess you don't see that error Jeroen?

Comment by Githook User [ 18/Nov/17 ]

Author:

{'name': 'A. Jesse Jiryu Davis', 'username': 'ajdavis', 'email': 'jesse@mongodb.com'}

Message: CDRIVER-2374 no arithmetic on void pointer
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/04aae47d8cd3a527a6846ba7d375bb312c818dae

Comment by Githook User [ 18/Nov/17 ]

Author:

{'name': 'A. Jesse Jiryu Davis', 'username': 'ajdavis', 'email': 'jesse@mongodb.com'}

Message: CDRIVER-2374 don't return void expression
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/917d8563a13ea1d85212baec2012214900cbd63e

Comment by A. Jesse Jiryu Davis [ 15/Nov/17 ]

Thanks, want to open a PR?

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