-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
yaml-cpp/node/impl.h:206 error 'operator=' should return a reference to *this [-Werror=effc++] #970
Comments
Indeed, I also see this:
|
Do u have any suggestion how to solve it ?
T
בתאריך יום ה׳, 7 בינו׳ 2021, 12:39, מאת btbouwens <notifications@github.com
…:
Indeed, I also see this:
In file included from
/workspace/software/lib/3rdparty/yaml-cpp/src/parse.cpp:7:
/workspace/software/lib/3rdparty/yaml-cpp/include/yaml-cpp/node/impl.h: In
member function 'YAML::Node& YAML::Node::operator=(const T&)':
/workspace/software/lib/3rdparty/yaml-cpp/include/yaml-cpp/node/impl.h:206:10:
warning: 'operator=' should return a reference to '*this' [-Weffc++]
206 | return *this;
| ^~~~~
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#970 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AJQIFLK3TDKGD2JX5NMZJ4LSYWFPRANCNFSM4VTIXVVQ>
.
|
No, I don't understand the problem. It looks OK to me actually. |
I opened a GCC bug #98841 about this. |
Jakub Jelinek wrote a fix for GCC for this, which "just" has to make it into a future release of GCC. If I understand the explanation of the bug correctly, there is nothing that can be done to the yaml-cpp code to workaround the warning for older compilers, short of disabling the warning: diff --git a/include/yaml-cpp/node/impl.h b/include/yaml-cpp/node/impl.h
--- a/include/yaml-cpp/node/impl.h
+++ b/include/yaml-cpp/node/impl.h
@@ -209,7 +209,15 @@ inline Node& Node::operator=(const T& rhs) {
if (!m_isValid)
throw InvalidNode(m_invalidKey);
Assign(rhs);
+// work around GCC PR c++/98841
+#if defined __GNUC__ && __GNUC__ < 11
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Weffc++"
+#endif
return *this;
+#if defined __GNUC__ && __GNUC__ < 11
+# pragma GCC diagnostic pop
+#endif
}
inline Node& Node::operator=(const Node& rhs) { Of course, that distracts a lot when reading the code. Including this or not may also depend on when the fix gets released and how long it takes for the developer-base of yaml-cpp to upgrade... |
Can we get this patch applied to the yaml-cpp repo, please? I'd like to be able to compile my own code without any warnings ( |
Is there a PR to fix this? If so, I'll review it. But it's totally not worth it to spam with a bunch of compiler-specific declarations just to fix a warning. |
maybe one option is to remove the WeffC++ option when the project is not the top level project. |
Is there a solution for this? Our project compiles with |
Yes and no:
So the question for the project maintainers is:
|
Our project is compiling on Ubuntu 20.04 (among others), which has GCC 9 |
I think a solution would be to disable all these extra warnings if this is being compiled as part of another project instead of as the main project. No need to block a project from using this library because of warnings |
It may be just warnings (for whatever reason), but some projects build with all warnings enabled and then use |
To answer questions from @olafmandel above:
Ideally, no.
Maybe? Depending on what that looks like.
Fine with me. I don't particularly care about warnings, personally. |
Minimize warnings when not the top-level project Should fix jbeder#970 and jbeder#764 when trying to add yaml-cpp to other project
on Linux build
The text was updated successfully, but these errors were encountered: