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

Lambda decay inside lambda capture puts class definition inside constructor arguments #491

Closed
erzyadev opened this issue Jul 26, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@erzyadev
Copy link

constexpr auto x = sizeof([var=+[]{}]{var();});

translates into

class __lambda_1_27
{
  public: 
  inline /*constexpr */ void operator()() const
  {
    var();
  }
  
  private: 
  void (*var)();
  
  public:
  __lambda_1_27(  
  class __lambda_1_33
  {
    public: 
    inline /*constexpr */ void operator()() const
    {
    }
    
    using retType_1_33 = auto (*)() -> void;
    inline constexpr operator retType_1_33 () const noexcept
    {
      return __invoke;
    }
    
    private: 
    static inline /*constexpr */ void __invoke()
    {
      __lambda_1_33{}.operator()();
    }
    
    
    public:
    // /*constexpr */ __lambda_1_33() = default;
    
  };
  
  void (*_var)())
  : var{_var}
  {}
  
};

constexpr const unsigned long x = sizeof(__lambda_1_27{+static_cast<void (*)()>(__lambda_1_33{}.operator __lambda_1_33::retType_1_33())});
@andreasfertig andreasfertig added the bug Something isn't working label Jul 27, 2022
andreasfertig added a commit that referenced this issue Sep 29, 2023
Fixed #491: Consider lambda in expression of lambda init capture.
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

2 participants