https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61659

            Bug ID: 61659
           Summary: Extra undefined symbol because of devirtualization
           Product: gcc
           Version: 4.10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rafael.espindola at gmail dot com
                CC: hubicka at gcc dot gnu.org

Given

struct generic_parser_base {
  virtual void getOption();
  void getExtraOptionNames() { getOption(); }
};
template <class DataType> struct parser : public generic_parser_base {
  virtual void getOption() {}
};
struct PassNameParser : public parser<int> {
  PassNameParser();
};
struct list {
  PassNameParser Parser;
  virtual void getExtraOptionNames() { return Parser.getExtraOptionNames(); }
};
list PassList;

gcc 4.9 and trunk will produce an undefined reference to
_ZN6parserIiE9getOptionEv (parser<int>::getOption()) which suggest that the
template is not being instantiated when the call is devirtualized.

Using -fno-devirtualize avoids the bug.

Reply via email to