hyperrealm / libconfig

C/C++ library for processing configuration files
https://hyperrealm.github.io/libconfig/
GNU Lesser General Public License v2.1
1.11k stars 362 forks source link

Only allow safe autoconverts? #162

Closed umanwizard closed 1 year ago

umanwizard commented 4 years ago

It would be nice to have a setting to allow safe auto-conversions. Currently trying to read an int as int64 in libconfig++ throws an exception unless auto_convert is set, even though this can never lead to loss of data.

I don't want to turn auto_convert on in my application, as I don't want people specifying floats and having them get truncated down to ints, but I'd like for people to be able to leave off the 'L' when specifying integers, and then later cast those to int64.

hyperrealm commented 1 year ago

This was fixed in 0a5cfd99532531500daa1b459257636d3220afc8 libconfig++ will now silently convert int64<->int as long as it's within range, and otherwise it throws a new SettingRangeException

umanwizard commented 1 year ago

Thank you!