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

inclusion of fmt/format-inl.h header causes compile fault (regression after 10.2.1) #3969

Closed
grooverdan opened this issue May 22, 2024 · 1 comment

Comments

@grooverdan
Copy link

Bisected to d707292 the inclusion of the generated compile header fails include/fmt/format-inl.h

Our code: https://github.com/MariaDB/server/blob/mariadb-10.11.8/sql/item_strfunc.cc#L61

removing the following didn't solve the compile problem:

#define FMT_STATIC_THOUSANDS_SEPARATOR ','
#define FMT_HEADER_ONLY 1
$ cmake --build . --target sql
[1/2] Building CXX object sql/CMakeFiles/sql.dir/item_strfunc.cc.o
FAILED: sql/CMakeFiles/sql.dir/item_strfunc.cc.o 
/usr/lib64/ccache/clang++ -DHAVE_CONFIG_H -DHAVE_EVENT_SCHEDULER -DHAVE_POOL_OF_THREADS -DMYSQL_SERVER -D_FILE_OFFSET_BITS=64 -I/home/dan/repos/mariadb-server-10.11/wsrep-lib/include -I/home/dan/repos/mariadb-server-10.11/wsrep-lib/wsrep-API/v26 -I/home/dan/repos/build-mariadb-server-10.11/include -I/home/dan/repos/mariadb-server-10.11/include/providers -I/home/dan/repos/mariadb-server-10.11/include -I/home/dan/repos/mariadb-server-10.11/sql -I/home/dan/repos/build-mariadb-server-10.11/sql -I/home/dan/repos/mariadb-server-10.11/tpool -I/home/dan/repos/inst-fmt/include -fstack-protector --param=ssp-buffer-size=4 -O2 -g -DNDEBUG -fno-omit-frame-pointer -D_FORTIFY_SOURCE=2 -DDBUG_OFF -Wall -Wdeclaration-after-statement -Wenum-compare -Wenum-conversion -Wextra -Wformat-security -Wmissing-braces -Wno-init-self -Wno-null-conversion -Wno-unused-parameter -Wno-unused-private-field -Woverloaded-virtual -Wnon-virtual-dtor -Wvla -Wwrite-strings -std=gnu++11   -DHAVE_OPENSSL -DOPENSSL_API_COMPAT=0x10100000L -MD -MT sql/CMakeFiles/sql.dir/item_strfunc.cc.o -MF sql/CMakeFiles/sql.dir/item_strfunc.cc.o.d -o sql/CMakeFiles/sql.dir/item_strfunc.cc.o -c /home/dan/repos/mariadb-server-10.11/sql/item_strfunc.cc
In file included from /home/dan/repos/mariadb-server-10.11/sql/item_strfunc.cc:61:
In file included from /home/dan/repos/inst-fmt/include/fmt/format-inl.h:25:
In file included from /home/dan/repos/inst-fmt/include/fmt/format.h:54:
/home/dan/repos/inst-fmt/include/fmt/base.h:1338:23: error: no matching member function for call to 'format'
 1338 |     ctx.advance_to(cf.format(*static_cast<qualified_type*>(arg), ctx));
      |                    ~~~^~~~~~
/home/dan/repos/inst-fmt/include/fmt/base.h:1319:21: note: in instantiation of function template specialization 'fmt::detail::value<fmt::context>::format_custom_arg<String, fmt::formatter<String>>' requested here
 1319 |     custom.format = format_custom_arg<
      |                     ^
/home/dan/repos/inst-fmt/include/fmt/base.h:1575:10: note: in instantiation of function template specialization 'fmt::detail::value<fmt::context>::value<String>' requested here
 1575 |   return {arg_mapper<Context>().map(val)};
      |          ^
/home/dan/repos/inst-fmt/include/fmt/base.h:1582:16: note: in instantiation of function template specialization 'fmt::detail::make_arg<true, fmt::context, String, 0>' requested here
 1582 |   arg.value_ = make_arg<true, Context>(val);
      |                ^
/home/dan/repos/mariadb-server-10.11/sql/item_strfunc.cc:1461:35: note: in instantiation of function template specialization 'fmt::detail::make_arg<fmt::context, String>' requested here
 1461 |       vargs[carg-1]= fmt::detail::make_arg<ctx>(*parg);
      |                                   ^
/home/dan/repos/mariadb-server-10.11/sql/item_strfunc.cc:1385:10: note: candidate function template not viable: 'this' argument has type 'const fmt::formatter<String>', but method is not marked const
 1385 |     auto format(String c, FormatContext& ctx) -> decltype(ctx.out()) {
      |          ^
1 error generated.
ninja: build stopped: subcommand failed.
$ /usr/lib64/ccache/clang++ --version
clang version 17.0.6 (Fedora 17.0.6-2.fc39)
Target: x86_64-redhat-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
@grooverdan
Copy link
Author

nm - our problem

diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index 19e011d54f8..28d7ee71453 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -1382,7 +1382,7 @@ bool Item_func_sformat::fix_length_and_dec(THD *thd)
 namespace fmt {
   template <> struct formatter<String>: formatter<string_view> {
     template <typename FormatContext>
-    auto format(String c, FormatContext& ctx) -> decltype(ctx.out()) {
+    auto format(String c, FormatContext& ctx) const -> decltype(ctx.out()) {
       string_view name = { c.ptr(), c.length() };
       return formatter<string_view>::format(name, ctx);
     };
```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant