Menu

returnTempReference false positive with explicit template function specialization

2023-08-07
2023-08-07
  • Maxim Yanchenko

    Maxim Yanchenko - 2023-08-07
    template<typename T> inline static T strConv(const std::string& str);
    
    template<> inline const std::string& strConv(const std::string& str) { return str; }
    template<> inline long strConv(const std::string&) { return 0; }
    
    inline static const std::string& f(const std::string& attr)
    {
        return strConv<const std::string&>(attr);
    }
    

    It says that the call to strConv inside f is returnTempReference.
    This only happens when you have the specialization for long (which is NOT called inside f!)

     
  • CHR

    CHR - 2023-08-07

    Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/11864

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.