svn commit: r285644 - head/contrib/sqlite3
Pedro Giffuni
pfg at FreeBSD.org
Fri Jul 17 22:53:09 UTC 2015
On 07/17/15 17:26, Peter Jeremy wrote:
> On 2015-Jul-16 22:07:14 +0000, "Pedro F. Giffuni" <pfg at FreeBSD.org> wrote:
>> Log:
> ...
>> sqlite: clean a couple of invocations of memcpy(3)
>>
>> Found almost accidentally by our native gcc when enhanced with
>> FORTIFY_SOURCE.
> ...
>> - memcpy((void *)&aHdr[1], (void *)&pWal->hdr, sizeof(WalIndexHdr));
>> + memcpy((void *)&aHdr[1], (const void *)&pWal->hdr, sizeof(WalIndexHdr));
>> walShmBarrier(pWal);
>> - memcpy((void *)&aHdr[0], (void *)&pWal->hdr, sizeof(WalIndexHdr));
>> + memcpy((void *)&aHdr[0], (const void *)&pWal->hdr, sizeof(WalIndexHdr));
> If the compiler complained about that, the compiler is broken.
The change was rather collateral (read cosmetical) to the real warning
which remains unfixed.
The compiler warning is this:
...
===> lib/libsqlite3 (obj,depend,all,install)
cc1: warnings being treated as errors
/scratch/tmp/pfg/head/lib/libsqlite3/../../contrib/sqlite3/sqlite3.c: In
function 'walIndexWriteHdr':
/scratch/tmp/pfg/head/lib/libsqlite3/../../contrib/sqlite3/sqlite3.c:49490:
warning: passing argument 1 of 'memcpy' discards qualifiers from pointer
target type
/scratch/tmp/pfg/head/lib/libsqlite3/../../contrib/sqlite3/sqlite3.c:49492:
warning: passing argument 1 of 'memcpy' discards qualifiers from pointer
target type
--- sqlite3.So ---
*** [sqlite3.So] Error code 1
...
make[6]: stopped in /scratch/tmp/pfg/head/lib/libsqlite3
It only happens when using the experimental FORTIFY_SOURCE support [1],
and it only happens with gcc (the base one is the only tested).
Yes, I am suspecting a compiler bug but gcc has been really useful to find
bugs in fortify_source.
> 'const'
> is a promise to the caller that the given parameter will not be modified
> by the callee. There's no requirement that the passed argument be const.
> As bde commented, the casts are all spurious.
And since this is contrib'ed code I am not going through the
code churn but upstream has been notified.
Pedro.
[1] https://reviews.freebsd.org/D3043
More information about the svn-src-all
mailing list