The following code fail to compile under cygwin. The relevant error message is:
...: undefined reference to `Base::x'
collect2: ld returned 1 exit status
However if I change the statement "y=-x" to "y=x", then it compiles fine.


class Base
{
  public:
    virtual void f () = 0;
    static const double x = 1;
};

class Derived : public Base
{
  public:
    Derived () {};
    void f () { double y = -x; };
};

int main()
{
  Derived foo;
  return 0;
}
~


-- 
           Summary: fail to link to static const double
           Product: gcc
           Version: 3.4.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dennis0yang at gmail dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31904

Reply via email to