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

            Bug ID: 79378
           Summary: lambda init-capture adds const
           Product: gcc
           Version: 7.0.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: barry.revzin at gmail dot com
  Target Milestone: ---

Minimal example:

template <class T, class U> struct is_same { static constexpr bool value =
false; };
template <class T> struct is_same<T, T> { static constexpr bool value = true;
};

int main() {
    int i = 0;
    return [j = i]() {
        static_assert(is_same<decltype(j), int>::value, "!");
        return j;
    }();
}

The static_assert fires on gcc 7 (and every other version I've tried) because
it says that decltype(j) is const int. If the lambda were marked mutable, then
decltype(j) is reported correct as int.

Reply via email to