Welcome, Guest. Please login or register.

Author Topic: Please help me stop insane SASC warning 317  (Read 2323 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline ChaosLordTopic starter

  • Hero Member
  • *****
  • Join Date: Nov 2003
  • Posts: 2608
    • Show only replies by ChaosLord
    • http://totalchaoseng.dbv.pl/news.php
Please help me stop insane SASC warning 317
« on: September 09, 2004, 07:47:04 PM »
How do I stop all these insane warnings?

Do all C Compilers do this?  Or just SASC?

Code: [Select]

  int count,color[256],halfcolor[256];

// I put this loop here to try to
// stop jillions of 'possibly uninitialized variable "color"' warnings
// BUT IT HAS NO EFFECT!
  FOR (count=0;count<=256; count++) DO
     color[count]=0; halfcolor[count]=0;
  NEXT // count++


Here are the warnings I get when I compile with optimize=on

info.c 313 Warning 317: possibly uninitialized variable &quot;color&quot;
info.c 321 Warning 317: possibly uninitialized variable &quot;halfcolor&quot;
info.c 328 Warning 317: possibly uninitialized variable &quot;halfcolor&quot;
info.c 335 Warning 317: possibly uninitialized variable &quot;color&quot;
info.c 338 Warning 317: possibly uninitialized variable &quot;color&quot;
info.c 343 Warning 317: possibly uninitialized variable &quot;color&quot;
info.c 349 Warning 317: possibly uninitialized variable &quot;halfcolor&quot;
info.c 352 Warning 317: possibly uninitialized variable &quot;halfcolor&quot;
info.c 357 Warning 317: possibly uninitialized variable &quot;halfcolor&quot;
info.c 362 Warning 317: possibly uninitialized variable &quot;halfcolor&quot;
info.c 365 Warning 317: possibly uninitialized variable &quot;halfcolor&quot;
info.c 370 Warning 317: possibly uninitialized variable &quot;halfcolor&quot;
info.c 376 Warning 317: possibly uninitialized variable &quot;color&quot;
info.c 379 Warning 317: possibly uninitialized variable &quot;color&quot;
info.c 382 Warning 317: possibly uninitialized variable &quot;color&quot;
info.c 387 Warning 317: possibly uninitialized variable &quot;color&quot;
info.c 390 Warning 317: possibly uninitialized variable &quot;color&quot;
info.c 397 Warning 317: possibly uninitialized variable &quot;halfcolor&quot;
info.c 400 Warning 317: possibly uninitialized variable &quot;halfcolor&quot;
info.c 403 Warning 317: possibly uninitialized variable &quot;halfcolor&quot;
info.c 408 Warning 317: possibly uninitialized variable &quot;halfcolor&quot;
info.c 411 Warning 317: possibly uninitialized variable &quot;halfcolor&quot;
info.c 417 Warning 317: possibly uninitialized variable &quot;halfcolor&quot;
info.c 420 Warning 317: possibly uninitialized variable &quot;halfcolor&quot;
info.c 423 Warning 317: possibly uninitialized variable &quot;halfcolor&quot;
info.c 428 Warning 317: possibly uninitialized variable &quot;halfcolor&quot;
info.c 431 Warning 317: possibly uninitialized variable &quot;halfcolor&quot;


I don't want to use ignore=317

I want to be warned about REAL possibly uninitialized variables.

color and halfcolor ARE initialized.

How can I stop these fake warnings without stopping the real
warnings?
Wanna try a wonderfull strategy game with lots of handdrawn anims,
Magic Spells and Monsters, Incredible playability and lastability,
English speech, etc. Total Chaos AGA
 

Offline Trev

  • Hero Member
  • *****
  • Join Date: May 2003
  • Posts: 1550
  • Country: 00
    • Show only replies by Trev
Re: Please help me stop insane SASC warning 317
« Reply #1 on: September 09, 2004, 07:57:59 PM »
color and halfcolor *aren't* initialized--they're only declared. You'll need to do something like this to get rid of the warning:

Code: [Select]

int count = 256, color[256] = {0}, halfcolor[256] = {0};

Or,
Code: [Select]

#define COUNT 256

fn()
{
    int color[COUNT] = {0}, halfcolor[COUNT] = {0};
}

Are FOR, DO, and NEXT SASC-specific macros? Using a standard C for-loop might disable the warning as well, but initializing the variables as part of the declaration should allow the compiler to do the optimization for you.

Trev
 

Offline PiR

  • Full Member
  • ***
  • Join Date: Apr 2003
  • Posts: 148
    • Show only replies by PiR
Re: Please help me stop insane SASC warning 317
« Reply #2 on: September 13, 2004, 04:42:22 PM »
I've observed that SAS/C is sometimes 'overprotective' in case of uninitialized variables, but at least from my observations, it happened mostly with conditional instructions, like:

Code: [Select]

int i;
int j;

/* blablabla */

if( i == 0 ) {
  j = 0; // initailized really conditionally
}

if( i == 0 ) {
  printf( &quot;%d&quot;, j ); // whenever used its always initialized
}


In this case it is hard to judge, just having list of warnings and sample of code to prove its wrong. Sometimes That Important Something is hidden in the place of code we do not expect it at all.
However I don't know really - mayby it is just like so. By the way - which version of SAS/C are you using?

Anyway one VERY IMPORTANT COMMENT FROM ME:
Quote
 FOR (count=0;count<=256; count++) DO

carefull PLEASE(!!!):
count < 256
 

Offline ChaosLordTopic starter

  • Hero Member
  • *****
  • Join Date: Nov 2003
  • Posts: 2608
    • Show only replies by ChaosLord
    • http://totalchaoseng.dbv.pl/news.php
Re: Please help me stop insane SASC warning 317
« Reply #3 on: September 13, 2004, 06:13:24 PM »
carefull PLEASE(!!!):
count < 256

u r correct.  silly me. :)  thanx
Wanna try a wonderfull strategy game with lots of handdrawn anims,
Magic Spells and Monsters, Incredible playability and lastability,
English speech, etc. Total Chaos AGA
 

Offline ChaosLordTopic starter

  • Hero Member
  • *****
  • Join Date: Nov 2003
  • Posts: 2608
    • Show only replies by ChaosLord
    • http://totalchaoseng.dbv.pl/news.php
Re: Please help me stop insane SASC warning 317
« Reply #4 on: September 15, 2004, 04:03:58 PM »
@Trev

Thank u very much!  Problem solved thanx 2 ur professional insight.

I ur friend for life!   or 1 week, whichever comes first 8D
Wanna try a wonderfull strategy game with lots of handdrawn anims,
Magic Spells and Monsters, Incredible playability and lastability,
English speech, etc. Total Chaos AGA