Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C++ Insights - Episode 1: The invisible things - Invalid ImplicitCast #313

Closed
andreasfertig opened this issue May 23, 2020 · 0 comments
Closed
Labels
bug Something isn't working

Comments

@andreasfertig
Copy link
Owner

andreasfertig commented May 23, 2020

In C++ Insights - Episode 1: The invisible things there is an example:

struct A {};
struct B {
   explicit operator A() { return {}; }
};

void DangerousFunc(const A&) {}

int main()
{
  DangerousFunc(static_cast<A>(B{}));
}

The transformation that C++ Insights shows leads to:

DangerousFunc(static_cast<A>(static_cast<A>(B{}.operator A())));

which is incorrect. The first static_cast<A> is missing const.

It was initially reported by @peterkochlarsen and @DanielKhoshnoud.

@andreasfertig andreasfertig added the bug Something isn't working label May 23, 2020
andreasfertig added a commit that referenced this issue May 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant