NO

Author Topic: Unexpected warnings  (Read 4920 times)

Offline Robert

  • Member
  • *
  • Posts: 247
Unexpected warnings
« on: January 14, 2006, 08:32:32 AM »
Pelle's C version 4.00.13, IDE 4.00.50 on both XP and W98.

I've been using Timo's SQLite ppj files to build the SQLite library, dll and exe and am suddenly getting a couple of warnings that I am sure I never got before, for example,

Code: [Select]


build.c(345): warning #2115: Local 'pOld' is initialized but never used.
 
Line 345 is the second line in the snippet below

static void sqliteDeleteIndex(sqlite3 *db, Index *p){
  Index *pOld;

  assert( db!=0 && p->zName!=0 );
  pOld = sqlite3HashInsert(&db->aDb[p->iDb].idxHash, p->zName,
                          strlen(p->zName)+1, 0);
  assert( pOld==0 || pOld==p );
  freeIndex(p);
}


another is

Code: [Select]


expr.c(1082): warning #2115: Local 'pSrcList' is initialized but never used.

Line 1082 is the third line in the snippet below

static int nameResolverStep(void *pArg, Expr *pExpr){
  NameContext *pNC = (NameContext*)pArg;
  SrcList *pSrcList;
  Parse *pParse;

  if( pExpr==0 ) return 1;
  assert( pNC!=0 );
  pSrcList = pNC->pSrcList;
  pParse = pNC->pParse;

  if( ExprHasAnyProperty(pExpr, EP_Resolved) ) return 1;
  ExprSetProperty(pExpr, EP_Resolved);
#ifndef NDEBUG
  if( pSrcList && pSrcList->nAlloc>0 ){
    int i;
    for(i=0; i<pSrcList->nSrc; i++){
      assert( pSrcList->a[i].iCursor>=0 && pSrcList->a[i].iCursor<pParse->nTab);
    }
  }
#endif




I did a reinstall of the compiler but am still having the problem. Any ideas what the problem may be ?

Robert Wishlaw

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Unexpected warnings
« Reply #1 on: January 14, 2006, 01:03:16 PM »
The error still persist if you define NDEBUG?
Maybe the code where you use the variables is conditionally not compiled.
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2266
    • http://www.smorgasbordet.com
Unexpected warnings
« Reply #2 on: January 14, 2006, 03:11:39 PM »
I think it's the other way around:

If NDEBUG is defined, assert() will no nothing - so in the first snippet, pOld will be assigned a value, but the value is never used - hence the warning...

Basically same problem with second snippet, but the NDEBUG test is spelled out...

In other words: you must have NDEBUG defined now - but not before (when it "worked")...

Pelle
/Pelle

Offline Robert

  • Member
  • *
  • Posts: 247
Unexpected warnings
« Reply #3 on: January 14, 2006, 10:27:21 PM »
It is the -Ot, -Os etc.,  optimizing flag that triggers the production of the warnings. If optimization is turned OFF the warnings do not occur. NDEBUG has no effect on the triggering of the warnings.

Robert Wishlaw

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2266
    • http://www.smorgasbordet.com
Unexpected warnings
« Reply #4 on: January 14, 2006, 11:50:44 PM »
Well, OK - the warning will only be issued when optimizations are on (but NDEBUG will also affect things).

Anyway, it's still not a bug...

Pelle
/Pelle

Offline Robert

  • Member
  • *
  • Posts: 247
Not a bug
« Reply #5 on: January 15, 2006, 12:29:03 AM »
Thank you Pelle and Frankie. I should have posted this under Beginners Questions.

Robert Wishlaw