You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#include<iostream>
#include<memory>
std::shared_ptr<int> create() {
return std::make_shared<int>(42);
}
intmain()
{
constauto& car = create(); // 'const' disappeared!//However, the following does not compile://std::shared_ptr<int> & ar = create();//error: non-const lvalue reference to type 'shared_ptr<...>' cannot bind to a temporary of type 'shared_ptr<...>'//must be:const std::shared_ptr<int> & car2 = create();
}
is translated incorrectly:
#include<iostream>
#include<memory>
std::shared_ptr<int> create() {
return std::make_shared<int>(42);
}
intmain()
{
std::shared_ptr<int> & car = create(); // 'const' disappeared!//However, the following does not compile://std::shared_ptr<int> & ar = create();//error: non-const lvalue reference to type 'shared_ptr<...>' cannot bind to a temporary of type 'shared_ptr<...>'//must be:const std::shared_ptr<int> & car2 = create();
}
Similar happens with const auto&&.
The text was updated successfully, but these errors were encountered:
Due to lambdas there is special handling for QualType in case it is a
RecordDecl or a ClassTemplateSpecializationDecl. It appears that, if the
type is a ReferenceType the CV qualifiers come from the reference type
getPointeeTypeAsWritten(). Ohterwise they are empty. This fix adds
special handling for that, nearly the same way as TypePrinter.cpp does
it.
thanks for pointing this out. Totally correct, I dropped a const, as well as a possible volatile, here. There are a couple more places where this could occur. I pushed a fix for it, you can check it online.
The following example
is translated incorrectly:
Similar happens with
const auto&&
.The text was updated successfully, but these errors were encountered: