Skip to content

static lambda call operator is not convertible to function pointer on win32 #62594

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

Closed
faisalv opened this issue May 7, 2023 · 6 comments
Closed
Assignees
Labels
c++ clang:frontend Language frontend issues, e.g. anything involving "Sema" confirmed Verified by a second party lambda C++11 lambda expressions platform:windows

Comments

@faisalv
Copy link
Contributor

faisalv commented May 7, 2023

This code does not work with clang compiled with msvc.

  auto lstatic = []()  static  { return 0;  };
  int (*f2)(void) = lstatic; 

I am working on a quick patch to fix it (the wrong calling convention CC_X86ThisCall is getting assigned in spite of the static).

@faisalv faisalv self-assigned this May 7, 2023
@faisalv faisalv added c++ clang:frontend Language frontend issues, e.g. anything involving "Sema" platform:windows labels May 7, 2023
@llvmbot
Copy link
Member

llvmbot commented May 7, 2023

@llvm/issue-subscribers-c-1

@llvmbot
Copy link
Member

llvmbot commented May 7, 2023

@llvm/issue-subscribers-clang-frontend

@faisalv faisalv added c++23 lambda C++11 lambda expressions labels May 7, 2023
@llvmbot
Copy link
Member

llvmbot commented May 7, 2023

@llvm/issue-subscribers-c-2b

@AaronBallman AaronBallman added confirmed Verified by a second party and removed c++23 new issue labels May 7, 2023
@AaronBallman
Copy link
Collaborator

It took me a moment to spot it, but this is a 32-bit only issue: https://godbolt.org/z/P5zddjE43

@faisalv faisalv changed the title static lambda call operator is not convertible to function pointer on windows static lambda call operator is not convertible to function pointer on win32 May 7, 2023
@faisalv
Copy link
Contributor Author

faisalv commented May 8, 2023

faisalv added a commit that referenced this issue Sep 16, 2023
…tion pointer on win32

See issue #62594

This code does not work on win32:

  auto lstatic = []()  static  { return 0;  };
  int (*f2)(void) = lstatic;

Since a calling convention such as CC_X86ThisCall can rightly interfere with the implicit pointer to function conversion if erroneously marked on a static function, the fix entails checking the 'static' specifier on the lambda declarator prior to assigning it a calling convention of an non-static member (which pre-c++23 made sense).
ZijunZhaoCCK pushed a commit to ZijunZhaoCCK/llvm-project that referenced this issue Sep 19, 2023
…tion pointer on win32

See issue llvm#62594

This code does not work on win32:

  auto lstatic = []()  static  { return 0;  };
  int (*f2)(void) = lstatic;

Since a calling convention such as CC_X86ThisCall can rightly interfere with the implicit pointer to function conversion if erroneously marked on a static function, the fix entails checking the 'static' specifier on the lambda declarator prior to assigning it a calling convention of an non-static member (which pre-c++23 made sense).
zahiraam pushed a commit to tahonermann/llvm-project that referenced this issue Oct 24, 2023
…tion pointer on win32

See issue llvm#62594

This code does not work on win32:

  auto lstatic = []()  static  { return 0;  };
  int (*f2)(void) = lstatic;

Since a calling convention such as CC_X86ThisCall can rightly interfere with the implicit pointer to function conversion if erroneously marked on a static function, the fix entails checking the 'static' specifier on the lambda declarator prior to assigning it a calling convention of an non-static member (which pre-c++23 made sense).
zahiraam pushed a commit to tahonermann/llvm-project that referenced this issue Oct 24, 2023
…tion pointer on win32

See issue llvm#62594

This code does not work on win32:

  auto lstatic = []()  static  { return 0;  };
  int (*f2)(void) = lstatic;

Since a calling convention such as CC_X86ThisCall can rightly interfere with the implicit pointer to function conversion if erroneously marked on a static function, the fix entails checking the 'static' specifier on the lambda declarator prior to assigning it a calling convention of an non-static member (which pre-c++23 made sense).
@cor3ntin
Copy link
Contributor

Fixed in Clang 18

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ clang:frontend Language frontend issues, e.g. anything involving "Sema" confirmed Verified by a second party lambda C++11 lambda expressions platform:windows
Projects
None yet
Development

No branches or pull requests

5 participants