Skip to content

Building fails with "error: lvalue required as increment operand" #4129

@nlsweet

Description

@nlsweet

Compiler is gcc 8.3.1

Can reproduce on godbolt with this code:

#include "fmt/format.h"

int main() {
  char buffer[4];
  auto result = fmt::format_to(buffer, "{}", 12345);

}

Output on godbolt:

In file included from /opt/compiler-explorer/libs/fmt/trunk/include/fmt/format.h:41,
                 from <source>:2:
/opt/compiler-explorer/libs/fmt/trunk/include/fmt/base.h: In instantiation of 'struct fmt::v11::detail::is_output_iterator<char [4], char, void>':
/opt/compiler-explorer/libs/fmt/trunk/include/fmt/base.h:3025:11:   required by substitution of 'template<class OutputIt, class ... T, typename std::enable_if<fmt::v11::detail::is_output_iterator<typename std::remove_cv<typename std::remove_reference<_Tp>::type>::type, char>::value, int>::type <anonymous> > fmt::v11::remove_cvref_t<T> fmt::v11::format_to(OutputIt&&, fmt::v11::format_string<T ...>, T&& ...) [with OutputIt = char (&)[4]; T = {int}; typename std::enable_if<fmt::v11::detail::is_output_iterator<typename std::remove_cv<typename std::remove_reference<_Tp>::type>::type, char>::value, int>::type <anonymous> = <missing>]'
<source>:6:51:   required from here
/opt/compiler-explorer/libs/fmt/trunk/include/fmt/base.h:1583:48: error: lvalue required as increment operand
     It, T, void_t<decltype(*std::declval<It&>()++ = std::declval<T>())>>
                             ~~~~~~~~~~~~~~~~~~~^~
/opt/compiler-explorer/libs/fmt/trunk/include/fmt/base.h:1583:48: error: lvalue required as increment operand
Compiler returned: 1

We discovered this issue when trying to build the fmt package after cloning the repo from github. After cloning, mkdir build && cd build && cmake .. && make

Output from this:

[ 16%] Building CXX object test/CMakeFiles/base-test.dir/base-test.cc.o
In file included from /home/nlsweet/external/fmt/test/base-test.cc:12:
/home/nlsweet/external/fmt/include/fmt/base.h: In instantiation of ‘struct fmt::v11::detail::is_output_iterator<char [4], char, void>’:
/home/nlsweet/external/fmt/include/fmt/base.h:2936:11:   required by substitution of ‘template<class OutputIt, class ... T, typename std::enable_if<fmt::v11::detail::is_output_iterator<typename std::remove_cv<typename std::remove_reference<_Tp>::type>::type, char>::value, int>::type <anonymous> > fmt::v11::remove_cvref_t<T> fmt::v11::format_to(OutputIt&&, fmt::v11::format_string<T ...>, T&& ...) [with OutputIt = char (&)[4]; T = {int}; typename std::enable_if<fmt::v11::detail::is_output_iterator<typename std::remove_cv<typename std::remove_reference<_Tp>::type>::type, char>::value, int>::type <anonymous> = <missing>]’
/home/nlsweet/external/fmt/test/base-test.cc:729:51:   required from here
/home/nlsweet/external/fmt/include/fmt/base.h:1576:48: error: lvalue required as increment operand
     It, T, void_t<decltype(*std::declval<It&>()++ = std::declval<T>())>>
                             ~~~~~~~~~~~~~~~~~~~^~
/home/nlsweet/external/fmt/include/fmt/base.h:1576:48: error: lvalue required as increment operand
make[2]: *** [test/CMakeFiles/base-test.dir/build.make:76: test/CMakeFiles/base-test.dir/base-test.cc.o] Error 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions