Bug 59975 - [C++11] Bogus "declared using local type ‘...’, is used but never defined"
Summary: [C++11] Bogus "declared using local type ‘...’, is used but never defined"
Status: RESOLVED DUPLICATE of bug 51048
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: unknown
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-01-28 23:38 UTC by Paul Pluzhnikov
Modified: 2015-06-15 12:00 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Pluzhnikov 2014-01-28 23:38:47 UTC
Google ref: b/12785605

Test:

template <typename T>
struct AbstractThing {
  virtual ~AbstractThing() { }
  virtual const T* method() const = 0;
};

template <typename T>
struct ConcreteThing : public AbstractThing<T> {
  virtual ~ConcreteThing() { }
  virtual const T* method() const { return 0; }
};

int main()
{
  struct Foo { };

  AbstractThing<Foo>* concrete = new ConcreteThing<Foo>();
  int rc = (concrete->method() == 0) ? 0 : 1;
  delete concrete;
  return rc;
}


Using g++ (GCC) 4.9.0 20140128 (experimental)

g++ -std=c++11 t.cc
t.cc:4:20: error: 'const T* AbstractThing<T>::method() const [with T = main()::Foo]', declared using local type 'const main()::Foo', is used but never defined [-fpermissive]
   virtual const T* method() const = 0;
                    ^

Adding -fpermissive, the executable links and runs fine, so clearly the never-defined method is not *actually* used.
Comment 1 Paolo Carlini 2015-06-15 12:00:57 UTC
Dup.

*** This bug has been marked as a duplicate of bug 51048 ***