public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/105518] New: [rejects valid] nested lambda using an outer type alias fails with constexpr integer in that alias
@ 2022-05-07 15:21 leventyilmaz at gmail dot com
  2022-11-01 23:02 ` [Bug c++/105518] " pinskia at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: leventyilmaz at gmail dot com @ 2022-05-07 15:21 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105518

            Bug ID: 105518
           Summary: [rejects valid] nested lambda using an outer type
                    alias fails with constexpr integer in that alias
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: leventyilmaz at gmail dot com
  Target Milestone: ---

The following valid code is fails to compile. 

https://godbolt.org/z/v1sd9snGx

// Simple run-time to compile-time integer conversion:
template<class F>
auto toStatic(int i, F f) {
    switch(i) {
        case 0: return f( std::integral_constant<int, 0>{} );
        case 1: return f( std::integral_constant<int, 1>{} );
        case 2: return f( std::integral_constant<int, 2>{} );
        default: assert("too big");
    }
}


// example types:
struct Base {
    virtual void show() const = 0;
};
template <size_t I> struct F {
    template <size_t J> struct K : Base {
        void show() const override {
            std::cout << I << " " << J << std::endl;
        }
    };
};


// nested lambda complains "I" is not captured
// even though it is only being used at compile-time
void show(int i, int j) {
    return toStatic(i, [j](auto I) {
        using A = F<I>;
        // using A = F<decltype(I)::value>; // this works
        return toStatic(j, [](auto J)  {
            using impl = typename A::template K<J>;
            impl{}.show();
        });
    });
}


source>:32:19: error: 'I' is not captured
   32 |             using impl = typename A::template K<J>;
      |                   ^~~~

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-12-15 20:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-07 15:21 [Bug c++/105518] New: [rejects valid] nested lambda using an outer type alias fails with constexpr integer in that alias leventyilmaz at gmail dot com
2022-11-01 23:02 ` [Bug c++/105518] " pinskia at gcc dot gnu.org
2022-12-15 20:54 ` cvs-commit at gcc dot gnu.org
2022-12-15 20:56 ` ppalka at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).