[CDRIVER-643] Solaris Compiler warning Created: 12/May/15  Updated: 17/May/17  Resolved: 15/Dec/15

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

Type: Bug Priority: Minor - P4
Reporter: Jeroen Ooms [X] Assignee: Hannes Magnusson
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to CDRIVER-940 Build errors and warnings on mingw-w64 Closed
is related to CDRIVER-831 GCC 5 warnings Closed
is related to CDRIVER-818 Add support for Solaris Studio Compiler Closed

 Description   

Assorted compiler warnings for 1.1.5-dev. Some of these may be due to misconfiguration on my end, please tell me if so.

Solaris

/opt/SunProd/studio12u3/solarisstudio12.3/bin/cc -xc99 -m64 -I/usr/lib/64/R/include -DNDEBUG -I. -Iyajl -Ibson -Imongoc -include apple.h  -I/opt/csw/include  -DBSON_COMPILATION -DMONGOC_COMPILATION     -KPIC  -xlibmieee  -c mongoc/mongoc-index.c -o mongoc/mongoc-index.o
"mongoc/mongoc-index.c", line 41: warning: initializer does not fit or is out of range: -90

Any

bson/bson-timegm.c:180:19: warning: variable 'gmt' is not needed and will not be emitted [-Wunneeded-internal-declaration]
static const char       gmt[] = "GMT";

Windows mingw32

gcc -m32 -I"C:/PROGRA~1/R/R-32~1.0/include" -DNDEBUG -I../windows/openssl-1.0.1j/include -I../windows/libsasl-2.1.26/include -DLIBSASL_EXPORTS -DBSON_COMPILATION -DMONGOC_COMPILATION -I. -Iyajl -Ibson -Imongoc    -I"d:/RCompile/r-compiling/local/local320/include"  -Wno-unused-value -Wno-unused-but-set-variable -Wno-implicit-function-declaration   -O3 -Wall  -std=gnu99 -mtune=core2 -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 [-Wuninitialized]
bson/bson-iso8601.c:108:1: warning: 'millis_ptr' may be used uninitialized in this function [-Wuninitialized]

Windows mingw-w64

gcc -m32 -I"C:/PROGRA~1/R/R-32~1.0/include" -DNDEBUG -I../windows/openssl-1.0.1j/include -I../windows/libsasl-2.1.26/include -DLIBSASL_EXPORTS -DBSON_COMPILATION -DMONGOC_COMPILATION -I. -Iyajl -Ibson -Imongoc    -I"d:/RCompile/r-compiling/local/local320/include"  -Wno-unused-value -Wno-unused-but-set-variable -Wno-implicit-function-declaration   -O3 -Wall  -std=gnu99 -mtune=core2 -c bson/bson.c -o bson/bson.o
bson/bson.c: In function '_bson_as_json_visit_int64':
bson/bson.c:2334:4: warning: format '%i' expects argument of type 'int', but argument 3 has type 'int64_t' [-Wformat]
bson/bson.c: In function '_bson_as_json_visit_date_time':
bson/bson.c:2450:4: warning: format '%i' expects argument of type 'int', but argument 3 has type 'int64_t' [-Wformat]
ar rcs libbson.a bson/*.o

Windows mingw-w64

gcc -m32 -I"C:/PROGRA~1/R/R-32~1.0/include" -DNDEBUG -I../windows/openssl-1.0.1j/include -I../windows/libsasl-2.1.26/include -DLIBSASL_EXPORTS -DBSON_COMPILATION -DMONGOC_COMPILATION -I. -Iyajl -Ibson -Imongoc    -I"d:/RCompile/r-compiling/local/local320/include"  -Wno-unused-value -Wno-unused-but-set-variable -Wno-implicit-function-declaration   -O3 -Wall  -std=gnu99 -mtune=core2 -c mongoc/mongoc-buffer.c -o mongoc/mongoc-buffer.o
mongoc/mongoc-buffer.c: In function '_mongoc_buffer_append_from_stream':
mongoc/mongoc-buffer.c:181:23: warning: format '%u' expects argument of type 'unsigned int', but argument 5 has type 'long long unsigned int' [-Wformat]



 Comments   
Comment by Githook User [ 19/Jul/16 ]

Author:

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

Message: CDRIVER-643 unused variable "gmt"
Branch: master
https://github.com/mongodb/libbson/commit/4f93a978df6d40a5b6c279ea11348741500d8db3

Comment by Hannes Magnusson [ 15/Dec/15 ]

I should mention that we are trying very hard to expand our CI testmatrix.
See https://jira.mongodb.org/browse/CDRIVER-535 with current list of tasks that we hope to achieve.

Comment by Hannes Magnusson [ 15/Dec/15 ]

This is a bit messy ticket, difficult to get the current status of it..

I think I'm going to close it out, and if there is remaining work we'll need to create separate tickets for it.

As of last week Solaris using our "officially supported toolchain" runs cleaninly without any warnings when configured with --enable-maintainer-flags.
To ensure there won't be any regressions to this, we also added -Werror to the build, so any new warnings will fail the build and we'd have to fix them.

See:

Do note that we currently "do not support" -pedantic. I am also aware that clang may produce some other warnings, and Solaris Studio probably too.
Until we add these things into our testmatrix on Evergreen we can't officially support it as the work maintaining "warning free with all flags in the world" is just to much and nonproductive.

Comment by Githook User [ 04/Dec/15 ]

Author:

{u'username': u'bjori', u'name': u'Hannes Magnusson', u'email': u'bjori@php.net'}

Message: CDRIVER-643: Fix 'control reaches end of non-void function'
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/799bc15fecb9a82316049ec3fcf41953a8a78f03

Comment by Githook User [ 04/Dec/15 ]

Author:

{u'username': u'bjori', u'name': u'Hannes Magnusson', u'email': u'bjori@php.net'}

Message: CDRIVER-643: Fix 'missing braces around initializer'
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/714db7bc00e3938fda1716f440ccf89988dfb3da

Comment by Githook User [ 04/Dec/15 ]

Author:

{u'username': u'bjori', u'name': u'Hannes Magnusson', u'email': u'bjori@php.net'}

Message: CDRIVER-643: Fix "missing sentinel in function call"
Branch: master
https://github.com/mongodb/libbson/commit/74d5f3fdc0640879fbcb1ad62d673cc3c52cc26a

Comment by Jeroen Ooms [X] [ 24/Oct/15 ]

I just updated mongo-c-driver to the latest master branch and there are still a few warnings in Solaris Studio 12.3:

"mongoc/mongoc-topology-private.h", line 64: warning: typedef redeclared: mongoc_topology_t
"mongoc/mongoc-index.c", line 46: warning: initializer does not fit or is out of range: -90
"mongoc/mongoc-scram.c", line 835: warning: statement not reached
"mongoc/mongoc-stream.c", line 451: warning: statement not reached

And Linux with -pedantic

bson/bson-context-private.h:31:4: warning: type of bit-field ‘flags’ is a GCC extension [-Wpedantic]
 
bson/bson-iso8601.c:227:30: warning: ‘sec_ptr’ may be used uninitialized in this function [-Wmaybe-uninitialized]
bson/bson-iso8601.c:273:31: warning: ‘millis_ptr’ may be used uninitialized in this function [-Wmaybe-uninitialized]
 
mongoc/mongoc-util-private.h:34:28: warning: ISO C forbids braced-groups within expressions [-Wpedantic]
 # define _ignore_value(x) (({ __typeof__ (x) __x = (x); (void) __x; }))
                            ^

And on windows:

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 [-Wuninitialized]
bson/bson-iso8601.c:108:1: warning: 'millis_ptr' may be used uninitialized in this function [-Wuninitialized]

Comment by Hannes Magnusson [ 23/Oct/15 ]

The warning bson-timegm.c:180 is in (popularly) vendored code. It does no harm and the warning is superfluous. Fixing it is likelier to cause bugs then leaving it.

The mingw ones are covered in CDRIVER-940

Leaving the:

Solaris

/opt/SunProd/studio12u3/solarisstudio12.3/bin/cc -xc99 -m64 -I/usr/lib/64/R/include -DNDEBUG -I. -Iyajl -Ibson -Imongoc -include apple.h  -I/opt/csw/include  -DBSON_COMPILATION -DMONGOC_COMPILATION     -KPIC  -xlibmieee  -c mongoc/mongoc-index.c -o mongoc/mongoc-index.o
"mongoc/mongoc-index.c", line 41: warning: initializer does not fit or is out of range: -90

I don't know about this one, I'll have to look at it

Comment by A. Jesse Jiryu Davis [ 12/May/15 ]

Thanks for the report! Not all of these may be fixed until 1.2, but it's a goal to eventually compile without warnings on all supported platforms.

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