Bug 393038 - False positive check "function-args-by-value". Template override case.
Summary: False positive check "function-args-by-value". Template override case.
Status: ASSIGNED
Alias: None
Product: clazy
Classification: Developer tools
Component: general (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Sergio Martins
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-04-12 10:59 UTC by Roman
Modified: 2018-04-12 11:13 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Roman 2018-04-12 10:59:19 UTC
Hi,

Maybe this is duplicate for issue https://bugs.kde.org/show_bug.cgi?id=391812, but because i cannot check i create new issue.

In my project i have this code:
class MyClass
{
public:
    template <typename T>
    void SetAttribute(QDomElement &domElement, const QString &name, const T &value) const;
};

template <typename T>
inline void MyClass::SetAttribute(QDomElement &domElement, const QString &name, const T &value) const
{
    // See specification for xs:decimal
    const QLocale locale = QLocale::c();
    domElement.setAttribute(name, locale.toString(value).remove(locale.groupSeparator()));
}

template <>
inline void MyClass::SetAttribute<QString>(QDomElement &domElement, const QString &name, const QString &value) const
{
    domElement.setAttribute(name, value);
}

template <>
inline void MyClass::SetAttribute<QChar>(QDomElement &domElement, const QString &name, const QChar &value) const
{
    domElement.setAttribute(name, value);
}

template <>
inline void MyClass::SetAttribute<bool>(QDomElement &domElement, const QString &name, const bool &value) const
{
    domElement.setAttribute(name, value ? QStringLiteral("true") : QStringLiteral("false"));
}

Clazy correctly warns about bool and QChar arguments, but i cannot change the function declaration, it won't compile with error "no function template matches function template specialization 'SetAttribute'".