-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
cannot bind non-const lvalue reference of type ‘string&’ to an rvalue of type ‘string’ #3116
Comments
The compile error |
I found a code that may be the cause of the error. It appears to be a known problem (specification): fmtlib/fmt#3596 if(received == -1)
{
- m_logger.error("Failed to receive data: {}", utils::getErrorFromErrno());
+ std::string err = utils::getErrorFromErrno();
+ m_logger.error("Failed to receive data: {}", err);
exit(1);
} |
Hmm interesting this worked untill recently for me, that's why i kinda dismissed the reference error. I thought i might have screwed something up when changing the cmake files. Also i dont see where this issue is mentioned |
It appears to me that this change has caused the return value of And since the changed code is written in a header file, it is possible that the compiler did not build the code it deemed unreachable. Could it be that the compiler evaluated the changed code for the first time in an application that uses that library, resulting in a compile error? |
If i understood correctly what you said the yes that is a possibility. but you can find plenty of examples throughout the code where i do the same thing but not in a header file and it did not happen. https://github.com/Iuliean/SFW/blob/2d1bf050fcb98ea8feb94295edec91d43ee85f95/src/Connection.cpp#L26 This has pretty much always been there but no issues before. My assumption is that the cmake files are fucked somehow since when i build the code with the above mentioned cmake files and project structure it also tries to tries to build the spdlog cpp files. Also even weirder is that for me the change you mentioned works, it builds fine. if i revet back to the old one then yes it starts to fail again As soon as i add it in the context of the other app mc-server it starts to fail again. It seems defines are not passed through i think includes are not there even though they should be i think |
The compiler may change the scope of optimization depending on the compile-time options and the code that could be recognized on a per-translation basis. I can only suggest that if the change from rvalue to lvalue does not cause compile errors, then apply that change to all. EDIT: Sometimes a non-standard feature causes the compiler to treat an rvalue as an lvalue, as in the following question: https://stackoverflow.com/questions/11508607/rvalue-to-lvalue-conversion-visual-studio |
I found fmtlib/fmt#3589 that clearly explains the fmt changes related to this issue. |
I keep getting this error when building with cmake and i cant figure out what is happening
My project structure goes like this.
And these are the cmake files.
I hope i am not completely misusing cmake though
The text was updated successfully, but these errors were encountered: