This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
On Wed, 20 Aug 2003, Nathan Sidwell wrote:
> Ed Swierk wrote:
> > No, -fno-inline seems to have no effect for functions defined implicitly
> > inline (i.e. defined within a class definition). With
> > -fno-default-inline, the inline-ness is ignored, and code is generated as
> > for a regular function, whether or not the function is called. This lets
> > gcov indicate that the function isn't covered.
> I'm confused, where is the function emitted? the inline keyword is not just
> a hint, but will effect linkage.
I'm not using the inline keyword--just implicitly inline functions.
Here's a simple program illustrating the issue. Thing.h declares a class:
class Thing {
public:
void yelp() {
cout << "Eep!" << endl;
}
void nevercalled() {
cout << "Aww!" << endl;
}
virtual void holler() { }
};
Nothing.cpp uses it:
int main() {
Thing t;
t.yelp();
return 0;
}
When I compile with "g++ -ftest-coverage -fprofile-arcs -g -o Nothing
Nothing.cpp", run the program, and run gcov, this is what it shows for
Thing.h:
66.67% of 3 source lines executed in file Thing.h
class Thing {
public:
1 void yelp() {
1 cout << "Eep!" << endl;
}
void nevercalled() {
cout << "Aww!" << endl;
}
###### virtual void holler() { }
};
When I compile with "g++ -ftest-coverage -fprofile-arcs -fno-inline -g -o
Nothing Nothing.cpp", I get exactly the same result as above.
When I compile with "g++ -ftest-coverage -fprofile-arcs
-fno-default-inline -g -o Nothing Nothing.cpp", this is what it shows for
Thing.h:
40.00% of 5 source lines executed in file Thing.h
class Thing {
public:
1 void yelp() {
1 cout << "Eep!" << endl;
}
###### void nevercalled() {
###### cout << "Aww!" << endl;
}
###### virtual void holler() { }
};
The latter result is considerably more useful, as it accounts for the
function nevercalled.
Why does -fno-default-inline solve the problem, while -fno-inline has no
effect?
I am also wondering why I get linker errors when compiling my entire
codebase with -fno-default-inline, but I'll have to post a more
complicated example to illustrate that.
--Ed
--
Ed Swierk
eswierk@cs.stanford.eduAttachment:
Thing.h
Description: Text document
Attachment:
Nothing.cpp
Description: Text document
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |