Hello,
I just wanted to report a false positive syntaxError. My team uses brace init everywhere we can and we have some templates that make calls using explicit operator calls to get a value. Here is a simple example without a template.
#include<iostream>#include<cstdint>structcallable{intoperator()(){return42;}};intmain(){callablec;std::int32_tconstmyint=c.operator()();// <-- No syntaxError from cppcheckstd::cout<<myint<<'\n';std::int32_tconstanotherint{c.operator()()};// <-- This produces a syntaxError from cppcheckstd::cout<<anotherint<<'\n';}
This does not seem specific to the call operator. I have also seen this false positive with auto const data{ operator->() };
I can work-around this easily enough, but I wanted to report the false positive.
I tested this using cppcheck 2.18.3.
Thank you!
Joel
Last edit: Joel Shuman 2025-09-23
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I just wanted to report a false positive syntaxError. My team uses brace init everywhere we can and we have some templates that make calls using explicit
operator
calls to get a value. Here is a simple example without a template.This does not seem specific to the call operator. I have also seen this false positive with
auto const data{ operator->() };
I can work-around this easily enough, but I wanted to report the false positive.
I tested this using cppcheck 2.18.3.
Thank you!
Joel
Last edit: Joel Shuman 2025-09-23
Thanks for reporting. I filed https://trac.cppcheck.net/ticket/14151 about it.