Yeah, we saw this with Chromium, too. The patch we use is below.
I'm with Dr Hipp that this is really more of a GCC issue. If it was
literally a 0 constant, it would make sense to warn so that the code can be
removed. But it's only a 0 if you optimize a certain way.
-scott
diff --git a/third_party/sqlite/src/src/expr.c
b/third_party/sqlite/src/src/expr.c
index 4012f6c..65f211e 100644
--- a/third_party/sqlite/src/src/expr.c
+++ b/third_party/sqlite/src/src/expr.c
@@ -856,7 +856,9 @@ static Expr *exprDup(sqlite3 *db, Expr *p, int flags,
u8 **pzBuffer){
}else{
int nSize = exprStructSize(p);
memcpy(zAlloc, p, nSize);
- memset(&zAlloc[nSize], 0, EXPR_FULLSIZE-nSize);
+ if( EXPR_FULLSIZE>nSize ){
+ memset(&zAlloc[nSize], 0, EXPR_FULLSIZE-nSize);
+ }
}
/* Set the EP_Reduced, EP_TokenOnly, and EP_Static flags
appropriately. */
On Thu, Aug 20, 2015 at 3:13 AM, Bernhard Schommer <
bernhardschommer at gmail.com> wrote:
> Hi,
>
> the warning which is mentioned in the ticket
> f51d9501800de5a0fb69d5048ce6662981b461ec still occurs also with newer gcc
> versions. The ticket was closed after a gcc bug report was opened. The gcc
> bug was closed due to a missing testcase.
> I had a quick look at the problem and it seems that the warning is right
> since in certain context and with optimizations enabled gcc can prove
> that EXPR_FULLSIZE
> - nSize == 0 and thus the triggered warning for this is correct.
> Replacing
> memset(&zAlloc[nSize], 0, EXPR_FULLSIZE-nSize);
> By
> if(EXPR_FULLSIZE-nSize > 0)
> memset(&zAlloc[nSize], 0, EXPR_FULLSIZE-nSize);
> would remove the warning,
>
> Cheers,
> -Bernhard
> _______________________________________________
> sqlite-users mailing list
> sqlite-users at mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>