Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22153

Can GCC optimize code size for functions with the same body?

$
0
0

I'm debugging a C++ program with GDB and faced that different functions turned out to be the same. Here is what I mean by that:

some.hpp

class Base{   virtual bool foo() const;   virtual bool bar() const;}

some.cpp

bool Base::foo() const {  return false;}bool Base::bar() const {  return false;}

The problem is that in gdb I see the following:

(gdb) p someBaseObject->foo$1 = {bool (const Base * const)} 0xdeadf00d <Base::foo() const>(gdb) p someBaseObject->bar$2 = {bool (const Base * const)} 0xdeadf00d <Base::foo() const>

I suppose GCC optimizes those two functions to save code size. Does it? This complicates debugging though...


Viewing all articles
Browse latest Browse all 22153

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>