function pointer is not initializing to NULL

sharathyd sharath.yd@rediffmail.com
Tue Apr 15 12:01:00 GMT 2008


Hi Andrew,

 I'm not able to give that program because its huge. But i'm sure its
failing at this point. I'm also trying to recreate this problem by small
program but I couldn't! Here is some test cases...

 Compiled ----
 With debug flag (ie in debug mode) == its working 
 without debug flag and not initialization to NULL == its working
 without debug flag and initialization to NULL == its not working.
 
 I'm suspecting some runtime environment issue or optimization problem , Is
there gcc flag to suppress this!?

Thanks & Regards,
 Sharath.
 
 

Andrew Haley wrote:
> 
> sharathyd wrote:
>> Hi,
>> 
>> I'm using AIX 5.1 and gcc 4.0 version to build my software. Here I'm
>> finding
>> some problem in runtime.
>> Here we have static function pointer that is initialized to NULL. Here is
>> the below cases...
>> 
>> static int (*retrivalFunc)(char *attr, char *option, returnCode *codePtr,
>> char *buf) = NULL;
>> 
>> sampleFunc() {
>> 
>> if (attRetrivalfunc != NULL) {
>> return(retrivalFunc(attName, dataBuf,codePtr, msg));
>> }
>> }
>> 
>> Here at run time for the first only directly its coming to this if loop
>> (ie.
>> !=NULL case), and causing problem.
>> But if I remove the NULL initialization, its working fine. I think
>> 'static'
>> will initialize. But why this is not initializing if I explicitly do? Is
>> this problem with AIX environment or gcc? Thanks for any suggestion!
> 
> It's hard to tell because you haven't really given us enough information.
> 
> Can you produce a test case (a complete, compilable and runnable program)
> that demonstrates this problem?
> 
> Andrew.
> 
> 

-- 
View this message in context: http://www.nabble.com/function-pointer-is-not-initializing-to-NULL-tp16699155p16699535.html
Sent from the gcc - Help mailing list archive at Nabble.com.



More information about the Gcc-help mailing list