GCC-7 and later miscompile SQLite
(1) By Richard Hipp (drh) on 2020-07-21 18:52:28 [link] [source]
GCC version 7 and later will sometimes miscompile SQLite. Incorrect object code is generated if the -m32 option is used on X86_64 platforms and the optimizer is enabled using -Os or -O1. When this bug is hit, a query of the form:
Will give a result of -1. The bug only shows up when compiling with -m32 (which is probably rare) and only seems to cause problems for integer values between -2533274790395904 and -2251799813685249 (which is to say, 64-bit integers whose upper 16 bits are 0xfff7.)
See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96270 for the GCC bug report.
SQLite check-in 9679c0c61131f0e9 attempts to work around the problem. But there might instances of this problem that the work-around misses. Use caution if you are builting an application with GCC version 7 or later that uses the -m32 option.
This problem was discovered when I attempted to do a full release test on SQLite using a new install of Ubuntu 20.04 which uses gcc 9.3.0 by default. Previous releases were tested on Ubuntu 16.04 which uses gcc 5.4.0.
(2.1) By Ppro6 (Chanda) on 2020-07-23 15:26:37 edited from 2.0 in reply to 1 [link] [source]Deleted
(3.1) By Larry Brasfield (LarryBrasfield) on 2020-07-23 14:26:57 edited from 3.0 in reply to 2.0 [link] [source]
The issue posted by Richard has nothing to do with zlib or use of assert.h or its macros.
If you have a problem using SQLite, and wish to obtain assistance here for it, you need to describe what you have done, what result(s) went against your hope or expectation, and if it is not obvious, what you hoped or expected to see. Anything like "they do not work", without the details that allow others to form that same assessment, is useless.
And, please, refrain from the disfavored practice of thread hijacking. The thread title is more useful to others when posts under it stay on its topic.
(4.3) By Ppro6 (Chanda) on 2020-07-23 15:25:27 edited from 4.2 in reply to 3.0 [source]Deleted
(5) By Larry Brasfield (LarryBrasfield) on 2020-07-23 15:22:51 in reply to 4.2 [link] [source]
This is not the right thread for discussion of the issues you raise. I suggest you continue a previous thread if its topic is fit for that, or start another.