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

Add default copy constructor to SystemError #475

Merged
merged 3 commits into from
Feb 25, 2017

Conversation

dschmidt
Copy link
Contributor

This PR fixes
fmt/format.h:2387:3: error: definition of implicit copy constructor for 'SystemError' is deprecated because it has a user-declared destructor [-Werror,-Wdeprecated] ~SystemError() FMT_DTOR_NOEXCEPT;
in clang-3.9

@foonathan
Copy link
Contributor

@vitaut Why does it have a destructor anyway?

@foonathan foonathan closed this Feb 23, 2017
@dschmidt
Copy link
Contributor Author

So ... are you going to fix this otherwise? Want me to do anything?
Not sure what to conclude from a closed-with-no-path-forward-PR.

@foonathan foonathan reopened this Feb 23, 2017
@foonathan
Copy link
Contributor

Sorry, I hit the wrong button accidentally :D

@dschmidt
Copy link
Contributor Author

I'd assume to mark the destructor explicitly noexcept.

@foonathan
Copy link
Contributor

Yes, but it could also be defaulted then.

@vitaut
Copy link
Contributor

vitaut commented Feb 23, 2017

@dschmidt, thanks for the PR. Could you hide default behind a macro similar to FMT_OVERRIDE for C++-98 compatibility?

@foonathan, unfortunately the dtor is there for a reason. I don't remember the details but they can be dug out from the version control history.

@dschmidt
Copy link
Contributor Author

Yes, most probably. Checking.

@dschmidt
Copy link
Contributor Author

AFAICT defaulted and deleted functions are supported from the very same compiler versions and thus I used the same version macros as for the deleted functions

Copy link
Contributor

@vitaut vitaut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for updating the PR. Mostly looks good, just two minor comments.

fmt/format.h Outdated
# else
# define FMT_DEFAULTED {}
# define FMT_DEFAULTED_COPY_CTOR(TypeName) \
TypeName(const TypeName&) {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the defaulted copy ctor is equivalent to not having a user-defined copy ctor. Having one with an empty body will not work if the class has members. Therefore I suggest defining FMT_DEFAULTED_COPY_CTOR to nothing here:

#  define FMT_DEFAULTED_COPY_CTOR(TypeName)

FMT_DEFAULTED is not used and can probably be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Will define it to empty.

I added FMT_DEFAULTED analogously to FMT_DELETED because I thought it might come in handy at some point, but I certainly don't insist. Will remove if you prefer.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the defaulted copy ctor is equivalent to not having a user-defined copy ctor.

Note that this is not the case if the class has a user-defined move constructor. If no copy ctor is declared, it won't have a copy constructor. But by writing = default it will have one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are no move semantics in C++98 though...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's just something that should be kept in mind, just in case.

fmt/format.h Outdated
@@ -2405,6 +2422,7 @@ class SystemError : public internal::RuntimeError {
SystemError(int error_code, CStringRef message) {
init(error_code, message, ArgList());
}
FMT_DEFAULTED_COPY_CTOR(SystemError);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest moving semicolon to the definition FMT_DEFAULTED_COPY_CTOR to prevent it dangling if the latter is defined to empty.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense.

@dschmidt
Copy link
Contributor Author

As soon as you're happy with it, I would like to squash the commits.

@foonathan
Copy link
Contributor

Commits can be squashed when merging the PR automatically, no need for that.

@dschmidt
Copy link
Contributor Author

Any idea what's up with the mingw builds?

@foonathan
Copy link
Contributor

Master's also broken so not your fault.

@vitaut
Copy link
Contributor

vitaut commented Feb 25, 2017

Appveyor updated MinGW - gcc is 5.3.0 now. Typical.

@vitaut vitaut closed this Feb 25, 2017
@vitaut vitaut reopened this Feb 25, 2017
@vitaut
Copy link
Contributor

vitaut commented Feb 25, 2017

Oops, wrong thread.

@dschmidt
Copy link
Contributor Author

So are you happy with this now or do you want me to change anything still?

@vitaut
Copy link
Contributor

vitaut commented Feb 25, 2017

Looks good to me, thanks for addressing the comments. I'll fix the master and merge this in.

@dschmidt
Copy link
Contributor Author

Wooohoo, sounds good. Thanks for the quick feedback cycle!

@vitaut vitaut merged commit 589b93d into fmtlib:master Feb 25, 2017
@vitaut
Copy link
Contributor

vitaut commented Feb 25, 2017

Merged, thanks!

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

Successfully merging this pull request may close these issues.

3 participants