Skip to content

Missing implicit cast for compound operator #405

@mma666

Description

@mma666

Hi @andreasfertig

Thanks for creating great cppinsights! It's indeed so insightful! I noticed the operators doesn't expand for the built-in types like int and double, while it works for complex type objects. Here is my code

#include <complex>
using namespace std;

int main () {
  
  int q = 2;
  ++q;
  q--;
  q += 2.0;
  
  complex<int> com1{3,4};
  complex<int> com2(com1);
  
  com1 += com2;
  com1 = com1 + com2;;
  
  return 0;
}

and here is what I get from cppinsights

#include <complex>
using namespace std;

int main()
{
  int q = 2;
  ++q;
  q--;
  q += 2.0;
  complex<int> com1 = std::complex<int>{3, 4};
  complex<int> com2 = std::complex<int>(static_cast<const std::complex<int>>(com1));
  com1.operator+=(static_cast<const std::complex<int>>(com2));
  com1.operator=(std::operator+(static_cast<const std::complex<int>>(com1), static_cast<const std::complex<int>>(com2)));
  ;
  return 0;
}

Also, I guess, in the case of q += 2.0; the static_cast<int> is not shown. Are they real bugs?

Thank you.
Mehdi

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions