Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Probable UB in basic_value<> constructor #20

Closed
p-kalugin opened this issue Feb 1, 2018 · 4 comments
Closed

Probable UB in basic_value<> constructor #20

p-kalugin opened this issue Feb 1, 2018 · 4 comments
Assignees
Labels

Comments

@p-kalugin
Copy link

In several basic_value<> constructors the destructor is called on not-yet constructed object:

basic_value( ... )
{
   try {  ...  }
   catch( ... ) {
      this->~basic_value();  // <== here
      throw;
   }
}

This seems like UB, though I'm not prepared to cite the relevant part of the Standard now.
Anyway, this leads to destructors of base subobjects to be called twice: first time when you explicitly call ~basic_value() and second time after rethrow, when already constructed base subobject gets destructed.

@ColinH
Copy link
Member

ColinH commented Feb 1, 2018

There's definitely something wrong, we'll check the details later today.

@d-frey d-frey closed this as completed in b4c12f1 Feb 1, 2018
@ColinH
Copy link
Member

ColinH commented Feb 1, 2018

Thanks for letting us know about this issue, we looked at all cases and even found a problem not related to the new base class feature. It should all be fixed now.

@d-frey
Copy link
Member

d-frey commented Feb 1, 2018

@p-kalugin That was a really good catch, thank you! Could you review the fix, please? I think we covered all cases correctly now, but an additional pair of eyes won't hurt. :)

@p-kalugin
Copy link
Author

LGTM, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants