autocxx icon indicating copy to clipboard operation
autocxx copied to clipboard

Member initializers are ignored when checking for default constructors

Open bsilver8192 opened this issue 3 years ago • 2 comments

Expected Behavior

If members of types without default constructors have default initializers, they should not prevent treating a class as though it has a default constructor, when the default constructor is defaulted (implicitly or explicitly).

Actual Behavior

Only the types of member variables are examined.

I'm working on implementing more complete logic for detecting types with default constructors, but this needs more information from bindgen (see #124) so I'm going to leave it for now.

bsilver8192 avatar Feb 19 '22 09:02 bsilver8192

Workaround with minimal change on the C++ side: define an explicit default constructor (either = default or with an empty body). There might be some subtle changes in the behavior of that in C++, but I think they're all pretty esoteric.

If #815 is fixed before this, then = default will prevent autocxx from using that default constructor.

bsilver8192 avatar Feb 19 '22 22:02 bsilver8192

Next step here is to add a failing test. Marking 'good first issue' for anyone who wants to do that.

adetaylor avatar Apr 02 '23 02:04 adetaylor