Search code examples
c++compiler-errors

getting "expression list treated as compound expression in functional cast" CE, but everything looks just fine


I tried building this:
whole code (unordered_map.h): https://pastebin.com/u9aMaqRp
test: https://pastebin.com/KqrKwNt0
and got a CE out of nowhere...?

getting a strange compilation error while building this:

/home/bibaboba/CLionProjects/spring_2024/unordered_map.h:332:67: error: expression list treated as compound expression in functional cast [-fpermissive]
  332 |     Node(Hash& hasher, Args&&... args): NodeType(std::move<key_t>(key_t(std::forward<Args>(args)...)), std::move(value_t())),  hash(){
      |                                                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/bibaboba/CLionProjects/spring_2024/unordered_map.h:332:91: warning: ignoring return value of ‘constexpr _Tp&& std::forward(typename std::remove_reference<_Tp>::type&) [with _Tp = double&; typename std::remove_reference<_Tp>::type = double]’, declared with attribute ‘nodiscard’ [-Wunused-result]
  332 |     Node(Hash& hasher, Args&&... args): NodeType(std::move<key_t>(key_t(std::forward<Args>(args)...)), std::move(value_t())),  hash(){
      |                                                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~

the part with key_t constructor gets highlighted
I suppose there is something with unfolding the expression, but I see nothing wrong here...
tried googling this, but i am either a bad googler, or there is nothing useful on the internet:(


Solution

  • looks like I called a wrong constructor and tried to build double from double and char*... no clue why what I got was that exact error, but I guess I can close the post now...?