Operating System - HP-UX
1753510 Members
5206 Online
108795 Solutions
New Discussion

Unexpected warning for invoking member function through pointer to member function

 
rr42
Occasional Visitor

Unexpected warning for invoking member function through pointer to member function

I'm getting an interesting warning from aC++ 6.25 when trying to use a scope guard type object to invoke a member function via pointer to member. I've reduced my code down to a simple testcase which is shown below.

 

struct S {

    void mem_fun() {
    }

    int s_;
};

int main()
{
    S s;

    void (S::*func)() = &S::mem_fun;
    (s.*func)();

    return 0;
}

 The generated warning is as follows.

 

"t.cpp", line 15, procedure main: warning #20207-D: Out of bound access (In
          expression "*(char**)__tempVar_0", variable "__tempVar_0" [t.cpp:0]
          (type: struct S* ) has 4 bytes, reading byte range [0 .. 7].)

 I'm fairly certain that the warning is bogus. At this point, I've got two issues. First off, I'd like to know if this issue has been resolved with later versions of the compiler. Secondly, if the issue hasn't been resolved, I'd like to find out how I can get this issue filed with the compiler team. I'm having trouble getting support contract information, which is preventing me from filing bugs against the compiler.

 

Travis

3 REPLIES 3
Dennis Handly
Acclaimed Contributor

Re: Unexpected warning 20207 for invoking member function through pointer to member function

>I'm getting an interesting warning from aC++ A.06.25

 

What compiler options were you using?  I can't duplicate it.

 

>how I can get this issue filed. I'm having trouble getting support contract information, which is preventing me from filing bugs against the compiler.

 

Do you have a support contract for aC++?

Travis Vitek
Occasional Contributor

Re: Unexpected warning 20207 for invoking member function through pointer to member function

Oops, I left out the most important part.

 

[vitek@hokie] 243 % cat t.cpp; aCC -V; aCC +DD64 +w t.cpp

struct S {

    void mem_fun() {
    }

    int s_;
};

int main()
{
    S s;

    void (S::*func)() = &S::mem_fun;
    (s.*func)();

    return 0;
}

aCC: HP C/aC++ B3910B A.06.25.01 [May 17 2010]
"t.cpp", line 15, procedure main: warning #20207-D: Out of bound access (In
          expression "*(char**)__tempVar_0", variable "__tempVar_0" [t.cpp:0]
          (type: struct S* ) has 4 bytes, reading byte range [0 .. 7].)

[vitek@hokie] 244 %

 

I'm in the process of trying to find support contract information. So far I've found that our AllianceONE Partner Program account and all of the Passport accounts I can find don't have any support contract information at all.

 

Travis

Dennis Handly
Acclaimed Contributor

Re: Unexpected warning 20207 for invoking member function through pointer to member function

>aCC +DD64 +w t.cpp

 

I tried +DD64 but I also used +O2 and the message wasn't there.

 

Later I thought about the generated code and it is related to the code to handle virtual functions.  There is an IF that checks a bit in the pointer to member function and then assumes that the first void* in the struct is a pointer to the vtable.  That's where the warning occurs and why it is 8 and doesn't occur with +DD32.

 

But you can get the warning if s_ is char[2] for +DD32 but not for char[1].

 

>I've found that our AllianceONE Partner Program account and all of the Passport accounts I can find don't have any support contract information at all.

 

Yes, if you are a AllianceONE Partner you aren't likely to have a support contract at all.  You must pay for them.

You may be able to get your AllianceONE rep to file an enhancement for you.