SQLite

View Ticket
Login
Ticket Hash: f51d9501800de5a0fb69d5048ce6662981b461ec
Title: memset warning with gcc 4.3.3
Status: Closed Type: Compiler_Warning
Severity: Important Priority: Immediate
Subsystem: Unknown Resolution: External_Bug
Last Modified: 2010-01-13 08:26:00
Version Found In: 3.6.18
Description:
While compiling latest version i get:

In function ‘memset’, inlined from ‘exprDup’ at sqlite3.c:60527: /usr/include/bits/string3.h:82: warning: call to ‘__warn_memset_zero_len’ declared with attribute warning: memset used with constant zero length parameter; this could be due to transposed parameters

It seems really wrong.. i checked and the error is also in fossil.

Line is:

        memset(&zAlloc[nSize], 0, EXPR_FULLSIZE-nSize);

drh added on 2009-09-23 11:54:18:
The 3rd parameter to memset is not a constant and is frequently non-zero, as you can easily verify by adding:

     assert( EXPR_FULLSIZE - nSize == 0 );

To the line above the memset in question and seeing that the assertion fires rather easily.

This is a bug in GCC. It appears to be a harmless bug in that correct code is still generated, but a bug nevertheless.


anonymous added on 2010-01-11 14:13:28:
Opened GCC bug report here: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42688