Some questions about optimization,help me.

W

wqe

Hi,everyone:

the questionly code:
#include <iostream>

using namespace std;
class test
{
int x;

void func()
{

};
void func1()
{

};

public:
void f()
{
printf("%x\n",&x);
printf("%x\n",&test::func );
printf("%x\n",&test::func1 );
};
};

int main()
{
test a;
a.f();
test * ap = &a;
void(test::*pmem)(void)=&test::f;
printf("%x\n",pmem );
test b;
b.f();
test * bp = &b;
return 0;
}




if delete this 3 statements: test * ap = &a;
void(test::*pmem)
(void)=&test::f;
printf("%x\n",pmem );
test b;
in vs2003-release,in export map file and disassemble output file,
cannot
find the location of "f()".

There is an answer, the f() was defined in the class test.

but if I define test::f() out of the class test, like this:

class test
{
int x;

void func()
{

};
void func1()
{

};

public:
void f();
};

void test::f()
{
printf("%x\n",&x);
};



I also cannot find the location of "f()" in the output disassemble
file,why?

if I close the optimiztion(/0d)setting of this win32 console
program(vs2003 release), I
can find f() in the disassemble output file.
but if I open /0d,even add some parameters,returned something, and
defined
a local variable,I also cannot find f() in the disassemble output
file.

why?
 
J

John Harrison

wqe said:
Hi,everyone:

the questionly code:
#include <iostream>

using namespace std;
class test
{
int x;

void func()
{

};
void func1()
{

};

public:
void f()
{
printf("%x\n",&x);
printf("%x\n",&test::func );
printf("%x\n",&test::func1 );
};
};

int main()
{
test a;
a.f();
test * ap = &a;
void(test::*pmem)(void)=&test::f;
printf("%x\n",pmem );
test b;
b.f();
test * bp = &b;
return 0;
}




if delete this 3 statements: test * ap = &a;
void(test::*pmem)
(void)=&test::f;
printf("%x\n",pmem );
test b;
in vs2003-release,in export map file and disassemble output file,
cannot
find the location of "f()".

There is an answer, the f() was defined in the class test.

but if I define test::f() out of the class test, like this:

class test
{
int x;

void func()
{

};
void func1()
{

};

public:
void f();
};

void test::f()
{
printf("%x\n",&x);
};



I also cannot find the location of "f()" in the output disassemble
file,why?

if I close the optimiztion(/0d)setting of this win32 console
program(vs2003 release), I
can find f() in the disassemble output file.
but if I open /0d,even add some parameters,returned something, and
defined
a local variable,I also cannot find f() in the disassemble output
file.

why?

If you want to know how the Visual Studio 2003 compiler works then you
should ask on a Microsoft group. Try one of the groups in
microsoft.public.vc.*

This group is for C++ language questions only.

john
 
W

wqe

ok,John

telnet2008

If you want to know how the Visual Studio 2003 compiler works then you
should ask on a Microsoft group. Try one of the groups in
microsoft.public.vc.*

This group is for C++ language questions only.

john- Òþ²Ø±»ÒýÓÃÎÄ×Ö -

- ÏÔʾÒýÓõÄÎÄ×Ö -
 
I

Ian Collins

John said:
If you want to know how the Visual Studio 2003 compiler works then you
should ask on a Microsoft group. Try one of the groups in
microsoft.public.vc.*

This group is for C++ language questions only.
Do you have to quote the entire post in order to redirect it?
 
F

Fei Liu

wqe said:
Hi,everyone:

the questionly code:
#include <iostream>

using namespace std;
class test
{
int x;

void func()
{

};
void func1()
{

};

public:
void f()
{
printf("%x\n",&x);
printf("%x\n",&test::func );
printf("%x\n",&test::func1 );
};
};

int main()
{
test a;
a.f();
test * ap = &a;
void(test::*pmem)(void)=&test::f;
printf("%x\n",pmem );
test b;
b.f();
test * bp = &b;
return 0;
}




if delete this 3 statements: test * ap = &a;
void(test::*pmem)
(void)=&test::f;
printf("%x\n",pmem );
test b;
in vs2003-release,in export map file and disassemble output file,
cannot
find the location of "f()".

There is an answer, the f() was defined in the class test.

but if I define test::f() out of the class test, like this:

class test
{
int x;

void func()
{

};
void func1()
{

};

public:
void f();
};

void test::f()
{
printf("%x\n",&x);
};



I also cannot find the location of "f()" in the output disassemble
file,why?

if I close the optimiztion(/0d)setting of this win32 console
program(vs2003 release), I
can find f() in the disassemble output file.
but if I open /0d,even add some parameters,returned something, and
defined
a local variable,I also cannot find f() in the disassemble output
file.

why?

Hello there, your question is irrelevant in this group. But in essence,
your compiler is free to optimize away test::f under certain conditions
and inline the function directly at the call site. As long your final
executable works as expected, you shouldn't worry about these details.
 
V

Victor Bazarov

wufeng said:
please tell me how to reply the topic

But you did! If you want to quote, you need to learn to use
your news-reading software. And since it's one of those basic
tasks (and depends on the software you're using), please
consult with the 'alt.newbies' or the 'alt.usenet.newbies' or
the 'alt.usenet.software' forums. Good luck!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top