[CDRIVER-4789] prevent -Werror=conversion with GCC 12 Created: 27/Nov/23  Updated: 29/Nov/23  Resolved: 29/Nov/23

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

Type: Bug Priority: Minor - P4
Reporter: Kevin Albertson Assignee: Kevin Albertson
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Tracks: https://github.com/mongodb/mongo-c-driver/pull/1479/



 Comments   
Comment by Githook User [ 29/Nov/23 ]

Author:

{'name': 'Roland Hieber', 'email': 'rohieb@users.noreply.github.com', 'username': 'rohieb'}

Message: CDRIVER-4789 libbson: prevent -Werror=conversion with GCC 12 (#1479)

  • libbson: prevent -Werror=conversion with GCC 12

Building fails with GCC 12.3:

bson-iter.h:434:33: error: conversion from 'int64_t'

{aka 'long long int'}

to '__suseconds_t'

{aka 'long int'}

may change value [-Werror=conversion]
434 | tv->tv_usec = (value % 1000) * 1000;

~~~~~~~~~~~~~~^~~~~
cc1plus: all warnings being treated as errors

Do the same as with tv->tv_sec, and explicitely cast it to suseconds_t
on non-Win32 systems and to long on Win32.

  • use `time_t` in assignment to `tv_sec`

This matches specificiation in POSIX 2008.
Branch: r1.25
https://github.com/mongodb/mongo-c-driver/commit/02320e726906748c5d8be9316af564a4db9faa8a

Comment by Githook User [ 29/Nov/23 ]

Author:

{'name': 'Roland Hieber', 'email': 'rohieb@users.noreply.github.com', 'username': 'rohieb'}

Message: CDRIVER-4789 libbson: prevent -Werror=conversion with GCC 12 (#1479)

  • libbson: prevent -Werror=conversion with GCC 12

Building fails with GCC 12.3:

bson-iter.h:434:33: error: conversion from 'int64_t'

{aka 'long long int'}

to '__suseconds_t'

{aka 'long int'}

may change value [-Werror=conversion]
434 | tv->tv_usec = (value % 1000) * 1000;

~~~~~~~~~~~~~~^~~~~
cc1plus: all warnings being treated as errors

Do the same as with tv->tv_sec, and explicitely cast it to suseconds_t
on non-Win32 systems and to long on Win32.

  • use `time_t` in assignment to `tv_sec`

This matches specificiation in POSIX 2008.
Branch: master
https://github.com/mongodb/mongo-c-driver/commit/5e27ad6b21f1cba6c08120e6123f317bbfc67e5c

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