SQLite Forum

Compiler warnings in shell.c for amalgamation 3.34.0
Login

Compiler warnings in shell.c for amalgamation 3.34.0

(1) By HowardKapustein (howardk) on 2020-12-31 22:02:37 [link] [source]

FYI compiling the 3.34.0 amalgamation for x64 with /W4 produces warnings:

shell.c(4776) : error C4242: '=': conversion from 'int' to 'char', possible loss of data
shell.c(4797) : error C4242: '=': conversion from 'int' to 'char', possible loss of data
shell.c(13100) : error C4242: 'function': conversion from 'sqlite3_int64' to 'int', possible loss of data
shell.c(13110) : error C4242: 'function': conversion from 'sqlite3_int64' to 'int', possible loss of data
shell.c(13127) : error C4242: '=': conversion from 'sqlite3_int64' to 'int', possible loss of data
shell.c(18155) : error C4242: '=': conversion from 'sqlite3_int64' to 'int', possible loss of data
shell.c(18247) : error C4242: '=': conversion from 'int' to 'char', possible loss of data
shell.c(18251) : error C4242: '=': conversion from 'int' to 'char', possible loss of data

(2) By Gunter Hick (gunter_hick) on 2021-01-04 07:11:21 in reply to 1 [link] [source]

You failed to provide the compiler (and version thereof) used. If you examine the code, then warnings like these are almost always false positives.

(3) By Richard Hipp (drh) on 2021-01-04 18:19:21 in reply to 1 [link] [source]

I'm sorry you are having trouble.

None of the compilers that I have access to are able to replicate these warnings. I could try to patch the code to avoid the warnings, but being unable to replicate them myself, I have no way of verifying that any changes I make would be effective in suppressing the warnings.

You might trying telling us exactly what version of MSVC you are using and exactly what command-line you are using to get these warnings. (The "/W4" is a nice hint, but it is not the same as giving the exact command-line.)

(4) By HowardKapustein (howardk) on 2021-01-09 06:58:00 in reply to 3 [source]

Yes they're all harmless, but we use /WX so all warnings are treated as errors. I worked around it by switched to /W2 to compile this but it's noise if anyone else builds with /W4 so thought it'd be polite to add tweak the code to not warn.

My bad not including the compiler version and settings. Listed below

Key option to repro is /W4. Switch to /W2 and poof! No warnings

3001>Microsoft (R) C/C++ Optimizing Compiler Version 19.28.29395.4 for x64
3001>Copyright (C) Microsoft Corporation.  All rights reserved.
3001>   /FC
...various /I... options omitted for brevity...
3001>   /D_WIN64
3001>   /D_AMD64_
3001>   /DAMD64
3001>   /DCONDITION_HANDLING=1
3001>   /DNT_UP=1
3001>   /DNT_INST=0
3001>   /DWIN32=100
3001>   /D_NT1X_=100
3001>   /DWINNT=1
3001>   /D_WIN32_WINNT=0x0A00
3001>   /DWINVER=0x0A00
3001>   /D_WIN32_IE=0x0A00
3001>   /DWIN32_LEAN_AND_MEAN=1
3001>   /DDEVL=1
3001>   /DNDEBUG
3001>   /D_DLL=1
3001>   /D_MT=1
3001>   /wd4127
3001>   /wd4100
3001>   /DSQLITE_ENABLE_API_ARMOR
3001>   -D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE
3001>   /D_USE_DEV11_CRT
3001>   /D__WRL_CONFIGURATION_LEGACY__
3001>   /DEXECUTABLE_WRITES_SUPPORT=0
3001>   /c
3001>   /Zc:wchar_t-
3001>   /Zl
3001>   /Zp8
3001>   /Gy
3001>   /W4
3001>   /d1import_no_registry
3001>   /EHs-c-
3001>   /GR-
3001>   /GF
3001>   /GS
3001>   /Z7
3001>   /Oxs
3001>   /GL
3001>   /Z7
3001>   /Zc:rvalueCast
3001>   /w15043
3001>   /std:c++17
3001>   /Zc:noexceptTypes
3001>   -D_CONST_RETURN=
3001>   -D_CRT_SECURE_NO_WARNINGS
3001>   -D_CRT_NON_CONFORMING_SWPRINTFS
3001>   -D_CRT_NONSTDC_NO_WARNINGS
3001>   -D_NO_CPPLIB_VER
3001>   -D_CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS
3001>   /D_CRT_STDIO_INLINE=extern
3001>   /D_NO_CRT_STDIO_INLINE
3001>   /D_ACRTIMP_ALT=
3001>   /D_ALLOW_MSC_VER_MISMATCH
3001>   /D_ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH
3001>   /D_ALLOW_RUNTIME_LIBRARY_MISMATCH
3001>   /D_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS
3001>   /D_STL_EXTRA_DISABLED_WARNINGS=4239
3001>   /D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING
3001>   /D_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS
3001>   /D_SILENCE_TR2_SYS_NAMESPACE_DEPRECATION_WARNING
3001>   /D_HAS_FUNCTION_ALLOCATOR_SUPPORT=1
3001>   /D_SILENCE_STDEXT_ALLOCATORS_DEPRECATION_WARNING
3001>   /D_HAS_STD_BYTE=0
3001>   /D_ENFORCE_MATCHING_ALLOCATORS=0
3001>   /D_HAS_FUNCTION_ALLOCATOR_SUPPORT=1
3001>   /D_SILENCE_STDEXT_ALLOCATORS_DEPRECATION_WARNING
3001>   /D_FULL_IOBUF
3001>   /d1nodatetime
3001>   /d2AllowCompatibleILVersions
3001>   /d2Zi+
3001>   /ZH:SHA_256
3001>   /wd4986
3001>   /wd4987
3001>   /wd4471
3001>   /wd4369
3001>   /wd4309
3001>   /wd4754
3001>   /wd4427
3001>   /d2DeepThoughtInliner-
3001>   /Zc:tlsGuards-
3001>   /Wv:19.23
3001>   /d2Qvec-mathlib-
3001>   /d2Qvec-sse2only
3001>   /Gw
3001>   /d1ignorePragmaWarningError
3001>   /wd4316
3001>   /wd4973
3001>   /DDONT_DISABLE_PCH_WARNINGS_IN_WARNING_H
3001>   /d2FH4
3001>   /Brepro
3001>   -D_HAS_MAGIC_STATICS=1
3001>   /Qspectre
3001>   /wd5045
3001>   /d2guardspecanalysismode:v1_0
3001>   /d2guardspecmode2
3001>   /guard:cf
3001>   /d1guard:xfg
3001>   /d2guardxfg
3001>   /D_CONTROL_FLOW_GUARD_XFG=1
3001>   /d2guardehcont
3001>   .\shell.c
3001>shell.c
3001>d:\repo\sqlite3\shell\shell.c(4776): warning C4242: '=': conversion from 'int' to 'char', possible loss of data
3001>errors in directory d:\repo\sqlite3\shell
3001>d:\repo\sqlite3\shell\shell.c(4776) : error C4242: '=': conversion from 'int' to 'char', possible loss of data
3001>d:\repo\sqlite3\shell\shell.c(4797): warning C4242: '=': conversion from 'int' to 'char', possible loss of data
3001>d:\repo\sqlite3\shell\shell.c(4797) : error C4242: '=': conversion from 'int' to 'char', possible loss of data
3001>d:\repo\sqlite3\shell\shell.c(13100): warning C4242: 'function': conversion from 'sqlite3_int64' to 'int', possible loss of data
3001>d:\repo\sqlite3\shell\shell.c(13100) : error C4242: 'function': conversion from 'sqlite3_int64' to 'int', possible loss of data
3001>d:\repo\sqlite3\shell\shell.c(13110): warning C4242: 'function': conversion from 'sqlite3_int64' to 'int', possible loss of data
3001>d:\repo\sqlite3\shell\shell.c(13110) : error C4242: 'function': conversion from 'sqlite3_int64' to 'int', possible loss of data
3001>d:\repo\sqlite3\shell\shell.c(13127): warning C4242: '=': conversion from 'sqlite3_int64' to 'int', possible loss of data
3001>d:\repo\sqlite3\shell\shell.c(13127) : error C4242: '=': conversion from 'sqlite3_int64' to 'int', possible loss of data
3001>d:\repo\sqlite3\shell\shell.c(18155): warning C4242: '=': conversion from 'sqlite3_int64' to 'int', possible loss of data
3001>d:\repo\sqlite3\shell\shell.c(18155) : error C4242: '=': conversion from 'sqlite3_int64' to 'int', possible loss of data
3001>d:\repo\sqlite3\shell\shell.c(18247): warning C4242: '=': conversion from 'int' to 'char', possible loss of data
3001>d:\repo\sqlite3\shell\shell.c(18247) : error C4242: '=': conversion from 'int' to 'char', possible loss of data
3001>d:\repo\sqlite3\shell\shell.c(18251): warning C4242: '=': conversion from 'int' to 'char', possible loss of data
3001>d:\repo\sqlite3\shell\shell.c(18251) : error C4242: '=': conversion from 'int' to 'char', possible loss of data