Invoking a deleted constructor in C++

34 Views Asked by At
class one: public two {
  public: explicit one (specifier const& use_case);
  one() = delete;
  void stat(Statistic val);
};

I need to test the above mentioned public interface "void stat(Statistic stat)" using Libfuzzer Library, So i wrote the code as follows:

Result: Error: call to deleted constructor 'one'
Question: Though the constructor is marked as explicitly deleted, how can i invoke or create a constructor and successfully execute the code snippet below?

extern "C" LLVM..(Data, Size) {
  Statistics val = Size; //Assigning the size;
  one obj; //Creating an instance of one
  obj.stat(val); //Call stat function and pass the value return 0;
}

Thanks in Advance.

Tried with this code snippet and was expecting to successfully pass the value

1

There are 1 best solutions below

2
MSalters On

"Reinvoke" is a weird word, it doesn't make sense in C++.

You create a constructor by changing one() = delete; to one() { /* function body */ }.

This cannot be done outside the class, or after compilation. It may be easier to create a one object by passing a specifier value.