Compiling with deleted functions fails with uclibc

191 Views Asked by At

I have a project I am porting from glibc to uclibc, and ran into this oddity.

gcc --std=c++11 Foo.cpp -o Foo-glibc
x86_64-linux-uclibc-gcc --std=c++11 Foo.cpp -o Foo-uclibc

// Compiles under glibc and uclibc
class Foo {
  Foo() = default;
  Foo(const Foo& arg) = delete;
  ~Foo() = default;
};

// Only compiles under glibc
class Foo {
  Foo() = default;
  Foo(const Foo& arg);
  ~Foo() = default;
};
Foo::Foo(const Foo& arg) = delete; // uclibc - Error: deleted definition of 'Foo::Foo(const Foo&)'

Why does this error occur? Is this expected behavior? Nothing I've read suggests that uclibc shouldn't be able to handle this.

1

There are 1 best solutions below

1
hellow On BEST ANSWER

It's most likely a bug in older gcc versions.

In 4.8.5 it worked, but in 5.1.0 it doesn't.

To quote Alan Birtles

[I]t makes no sense to declare a constructor in the class declaration[,] then delete it out of line. How would a consumer of the class know that the constructor is deleted?