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

-Wpedantic: ISO C++ did not adopt string literal operator templates taking an argument pack of characters #1267

Closed
binarytrails opened this issue Aug 16, 2019 · 14 comments

Comments

@binarytrails
Copy link

Hello!

I manged to fix the below error by providing the CXXFLAGS+=" -DFMT_USE_USER_DEFINED_LITERALS=0" in Autotools build of OpenDHT who has a dependency of libfmt from now on.

However, I think it would be better to put this flag to false by default to avoid specifying this flag in each project trying to use a new version of fmt along with -Wpedantic standard flag!

make[2]: Entering directory '/home/n0t/jami/ring-daemon/contrib/build/opendht/src'
/bin/sh ../libtool  --tag=CXX   --mode=compile g++ -DHAVE_CONFIG_H -I. -I..  -I/home/n0t/jami/ring-daemon/contrib/x86_64-pc-linux-gnu/include -fPIC -DOPENDHT_JSONCPP=1 -DOPENDHT_PROXY_HTTP_PARSER_FORK -DOPENDHT_PROXY_SERVER -DOPENDHT_PROXY_CLIENT -DOPENDHT_PUSH_NOTIFICATIONS -I../include/opendht    -I/home/n0t/jami/ring-daemon/contrib/x86_64-pc-linux-gnu/include -fPIC -DOPENDHT_JSONCPP=1 -DOPENDHT_PROXY_HTTP_PARSER_FORK -DOPENDHT_PROXY_SERVER -DOPENDHT_PROXY_CLIENT -DOPENDHT_PUSH_NOTIFICATIONS  -I/home/n0t/jami/ring-daemon/contrib/x86_64-pc-linux-gnu/include -DNDEBUG=1 -O3 -std=c++14 -fPIC -O3 -pedantic-errors -DMSGPACK_DISABLE_LEGACY_NIL -DMSGPACK_DISABLE_LEGACY_CONVERT -c -o libopendht_la-dhtrunner.lo `test -f 'dhtrunner.cpp' || echo './'`dhtrunner.cpp
libtool: compile:  g++ -DHAVE_CONFIG_H -I. -I.. -I/home/n0t/jami/ring-daemon/contrib/x86_64-pc-linux-gnu/include -fPIC -DOPENDHT_JSONCPP=1 -DOPENDHT_PROXY_HTTP_PARSER_FORK -DOPENDHT_PROXY_SERVER -DOPENDHT_PROXY_CLIENT -DOPENDHT_PUSH_NOTIFICATIONS -I../include/opendht -I/home/n0t/jami/ring-daemon/contrib/x86_64-pc-linux-gnu/include -fPIC -DOPENDHT_JSONCPP=1 -DOPENDHT_PROXY_HTTP_PARSER_FORK -DOPENDHT_PROXY_SERVER -DOPENDHT_PROXY_CLIENT -DOPENDHT_PUSH_NOTIFICATIONS -I/home/n0t/jami/ring-daemon/contrib/x86_64-pc-linux-gnu/include -DNDEBUG=1 -O3 -std=c++14 -fPIC -O3 -pedantic-errors -DMSGPACK_DISABLE_LEGACY_NIL -DMSGPACK_DISABLE_LEGACY_CONVERT -c dhtrunner.cpp  -fPIC -DPIC -o libopendht_la-dhtrunner.o
In file included from /home/n0t/jami/ring-daemon/contrib/x86_64-pc-linux-gnu/include/restinio/http_headers.hpp:16,
                 from /home/n0t/jami/ring-daemon/contrib/x86_64-pc-linux-gnu/include/restinio/request_handler.hpp:15,
                 from /home/n0t/jami/ring-daemon/contrib/x86_64-pc-linux-gnu/include/restinio/settings.hpp:18,
                 from /home/n0t/jami/ring-daemon/contrib/x86_64-pc-linux-gnu/include/restinio/all.hpp:12,
                 from ../include/opendht/http.h:28,
                 from ../include/opendht/dht_proxy_client.h:30,
                 from dhtrunner.cpp:27:
/home/n0t/jami/ring-daemon/contrib/x86_64-pc-linux-gnu/include/fmt/format.h:3475:55: error: ISO C++ did not adopt string literal operator templates taking an argument pack of characters [-Wpedantic]
 3475 | FMT_CONSTEXPR internal::udl_formatter<Char, CHARS...> operator""_format() {
      |                                                       ^~~~~~~~
make[2]: *** [Makefile:904: libopendht_la-dhtrunner.lo] Error 1
make[2]: Leaving directory '/home/n0t/jami/ring-daemon/contrib/build/opendht/src'
make[1]: *** [Makefile:515: install-recursive] Error 1
make[1]: Leaving directory '/home/n0t/jami/ring-daemon/contrib/build/opendht'
make: *** [../../contrib/src/opendht/rules.mak:42: .opendht] Error 2

Cheers,
Seva

References: https://github.com/citra-emu/citra/issues/4766, Stiffstream/restinio#45.

@foonathan
Copy link
Contributor

Or we could locally disable the warning; that is what I usually do.

@binarytrails
Copy link
Author

@foonathan I don't think it is the right solution as it is important to comply to this standard as stated:

-pedantic causes the compiler to actually comply to the C standard. Thus for maximal portability, specifying the standard revision is not enough, you must also use -pedantic (or -pedantic-errors) to ensure that GCC actually does comply to the letter of the standard.

https://stackoverflow.com/questions/2855121/what-is-the-purpose-of-using-pedantic-in-gcc-g-compiler

@foonathan
Copy link
Contributor

I meant something like this:

#    pragma GCC diagnostic push
#    pragma GCC diagnostic ignored "-Wpedantic"
#    ifdef __clang__
#        pragma GCC diagnostic ignored "-Wgnu-string-literal-operator-template"
#    endif

// operator

#    pragma GCC diagnostic pop

That disables the diagnostic for this piece of code. You can still use -pedantic, it just won't complain about it.

@binarytrails
Copy link
Author

@eao197 Do you think that it would that mean that RESTinio should patch this on the libfmt include in the chain call origin of restinio/http_headers.hpp:16?

@eao197
Copy link

eao197 commented Aug 16, 2019

@binarytrails
I can try that tomorrow. Which version of GCC do you use?

@vitaut
Copy link
Contributor

vitaut commented Aug 16, 2019

UDL templates were supposed to be disabled by default on GCC 9 and later: a6e8ed1, but it looks that version check is incorrect. A PR is welcome.

@binarytrails
Copy link
Author

@eao197 Sure thing! Thank you for looking into it.

n0t build $ gcc --version
gcc (GCC) 9.1.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

n0t build $ g++ --version
g++ (GCC) 9.1.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Thank you all for the feedback and help! It is highly appreciated :)

@vitaut
Copy link
Contributor

vitaut commented Aug 16, 2019

Actually, with the current version check UDL templates should already be disabled on GCC 9.1.

@vitaut vitaut closed this as completed Aug 16, 2019
@binarytrails
Copy link
Author

@vitaut but the error is there in fmt with gcc 9.1...

@vitaut
Copy link
Contributor

vitaut commented Aug 16, 2019

@binarytrails, the error message suggests that it's {fmt} 5.3. Does it happen on master?

@binarytrails
Copy link
Author

@vitaut I wish I reached that point in compiling but using master branch gave a bunch of other errors seen below. ofc, do you know when is the next fmt release?

/bin/sh ../libtool  --tag=CXX   --mode=compile g++ -DHAVE_CONFIG_H -I. -I..  -I/home/n0t/jami/ring-daemon/contrib/x86_64-pc-linux-gnu/include -fPIC -DOPENDHT_JSONCPP=1 -DOPENDHT_PROXY_HTTP_PARSER_FORK -DOPENDHT_PROXY_SERVER -DOPENDHT_PROXY_CLIENT -DOPENDHT_PUSH_NOTIFICATIONS -I../include/opendht    -I/home/n0t/jami/ring-daemon/contrib/x86_64-pc-linux-gnu/include -fPIC -DOPENDHT_JSONCPP=1 -DOPENDHT_PROXY_HTTP_PARSER_FORK -DOPENDHT_PROXY_SERVER -DOPENDHT_PROXY_CLIENT -DOPENDHT_PUSH_NOTIFICATIONS  -I/home/n0t/jami/ring-daemon/contrib/x86_64-pc-linux-gnu/include -DNDEBUG=1 -O3 -std=c++14 -fPIC -O3 -pedantic-errors -DMSGPACK_DISABLE_LEGACY_NIL -DMSGPACK_DISABLE_LEGACY_CONVERT -c -o libopendht_la-securedht.lo `test -f 'securedht.cpp' || echo './'`securedht.cpp
libtool: compile:  g++ -DHAVE_CONFIG_H -I. -I.. -I/home/n0t/jami/ring-daemon/contrib/x86_64-pc-linux-gnu/include -fPIC -DOPENDHT_JSONCPP=1 -DOPENDHT_PROXY_HTTP_PARSER_FORK -DOPENDHT_PROXY_SERVER -DOPENDHT_PROXY_CLIENT -DOPENDHT_PUSH_NOTIFICATIONS -I../include/opendht -I/home/n0t/jami/ring-daemon/contrib/x86_64-pc-linux-gnu/include -fPIC -DOPENDHT_JSONCPP=1 -DOPENDHT_PROXY_HTTP_PARSER_FORK -DOPENDHT_PROXY_SERVER -DOPENDHT_PROXY_CLIENT -DOPENDHT_PUSH_NOTIFICATIONS -I/home/n0t/jami/ring-daemon/contrib/x86_64-pc-linux-gnu/include -DNDEBUG=1 -O3 -std=c++14 -fPIC -O3 -pedantic-errors -DMSGPACK_DISABLE_LEGACY_NIL -DMSGPACK_DISABLE_LEGACY_CONVERT -c securedht.cpp  -fPIC -DPIC -o libopendht_la-securedht.o
/bin/sh ../libtool  --tag=CXX   --mode=compile g++ -DHAVE_CONFIG_H -I. -I..  -I/home/n0t/jami/ring-daemon/contrib/x86_64-pc-linux-gnu/include -fPIC -DOPENDHT_JSONCPP=1 -DOPENDHT_PROXY_HTTP_PARSER_FORK -DOPENDHT_PROXY_SERVER -DOPENDHT_PROXY_CLIENT -DOPENDHT_PUSH_NOTIFICATIONS -I../include/opendht    -I/home/n0t/jami/ring-daemon/contrib/x86_64-pc-linux-gnu/include -fPIC -DOPENDHT_JSONCPP=1 -DOPENDHT_PROXY_HTTP_PARSER_FORK -DOPENDHT_PROXY_SERVER -DOPENDHT_PROXY_CLIENT -DOPENDHT_PUSH_NOTIFICATIONS  -I/home/n0t/jami/ring-daemon/contrib/x86_64-pc-linux-gnu/include -DNDEBUG=1 -O3 -std=c++14 -fPIC -O3 -pedantic-errors -DMSGPACK_DISABLE_LEGACY_NIL -DMSGPACK_DISABLE_LEGACY_CONVERT -c -o libopendht_la-dhtrunner.lo `test -f 'dhtrunner.cpp' || echo './'`dhtrunner.cpp
libtool: compile:  g++ -DHAVE_CONFIG_H -I. -I.. -I/home/n0t/jami/ring-daemon/contrib/x86_64-pc-linux-gnu/include -fPIC -DOPENDHT_JSONCPP=1 -DOPENDHT_PROXY_HTTP_PARSER_FORK -DOPENDHT_PROXY_SERVER -DOPENDHT_PROXY_CLIENT -DOPENDHT_PUSH_NOTIFICATIONS -I../include/opendht -I/home/n0t/jami/ring-daemon/contrib/x86_64-pc-linux-gnu/include -fPIC -DOPENDHT_JSONCPP=1 -DOPENDHT_PROXY_HTTP_PARSER_FORK -DOPENDHT_PROXY_SERVER -DOPENDHT_PROXY_CLIENT -DOPENDHT_PUSH_NOTIFICATIONS -I/home/n0t/jami/ring-daemon/contrib/x86_64-pc-linux-gnu/include -DNDEBUG=1 -O3 -std=c++14 -fPIC -O3 -pedantic-errors -DMSGPACK_DISABLE_LEGACY_NIL -DMSGPACK_DISABLE_LEGACY_CONVERT -c dhtrunner.cpp  -fPIC -DPIC -o libopendht_la-dhtrunner.o
In file included from /home/n0t/jami/ring-daemon/contrib/x86_64-pc-linux-gnu/include/restinio/message_builders.hpp:15,
                 from /home/n0t/jami/ring-daemon/contrib/x86_64-pc-linux-gnu/include/restinio/request_handler.hpp:16,
                 from /home/n0t/jami/ring-daemon/contrib/x86_64-pc-linux-gnu/include/restinio/settings.hpp:18,
                 from /home/n0t/jami/ring-daemon/contrib/x86_64-pc-linux-gnu/include/restinio/all.hpp:12,
                 from ../include/opendht/http.h:28,
                 from ../include/opendht/dht_proxy_client.h:30,
                 from dhtrunner.cpp:27:
/home/n0t/jami/ring-daemon/contrib/x86_64-pc-linux-gnu/include/fmt/time.h: In member function ‘bool fmt::v5::localtime(time_t)::dispatcher::handle(tm*)’:
/home/n0t/jami/ring-daemon/contrib/x86_64-pc-linux-gnu/include/fmt/time.h:41:45: error: ‘FMT_NULL’ was not declared in this scope
   41 |     bool handle(std::tm *tm) { return tm != FMT_NULL; }
      |                                             ^~~~~~~~
/home/n0t/jami/ring-daemon/contrib/x86_64-pc-linux-gnu/include/fmt/time.h: In member function ‘bool fmt::v5::localtime(time_t)::dispatcher::fallback(fmt::v5::internal::null<>)’:
/home/n0t/jami/ring-daemon/contrib/x86_64-pc-linux-gnu/include/fmt/time.h:55:20: error: ‘FMT_NULL’ was not declared in this scope
   55 |       return tm != FMT_NULL;
      |                    ^~~~~~~~
/home/n0t/jami/ring-daemon/contrib/x86_64-pc-linux-gnu/include/fmt/time.h: In member function ‘bool fmt::v5::gmtime(time_t)::dispatcher::handle(tm*)’:
/home/n0t/jami/ring-daemon/contrib/x86_64-pc-linux-gnu/include/fmt/time.h:79:45: error: ‘FMT_NULL’ was not declared in this scope
   79 |     bool handle(std::tm *tm) { return tm != FMT_NULL; }
      |                                             ^~~~~~~~
/home/n0t/jami/ring-daemon/contrib/x86_64-pc-linux-gnu/include/fmt/time.h: In member function ‘bool fmt::v5::gmtime(time_t)::dispatcher::fallback(fmt::v5::internal::null<>)’:
/home/n0t/jami/ring-daemon/contrib/x86_64-pc-linux-gnu/include/fmt/time.h:92:20: error: ‘FMT_NULL’ was not declared in this scope
   92 |       return tm != FMT_NULL;
      |                    ^~~~~~~~
make[2]: *** [Makefile:904: libopendht_la-dhtrunner.lo] Error 1
make[2]: Leaving directory '/home/n0t/jami/ring-daemon/contrib/build/opendht/src'
make[1]: *** [Makefile:515: install-recursive] Error 1
make[1]: Leaving directory '/home/n0t/jami/ring-daemon/contrib/build/opendht'
make: *** [../../contrib/src/opendht/rules.mak:43: .opendht] Error 2

@vitaut
Copy link
Contributor

vitaut commented Aug 16, 2019

This doesn't look like master because the latter doesn't have fmt/time.h any more. I plan to release a new version as soon as I hear from the few remaining contributors on #1073 that they accept relaxing licensing terms.

@cement-head
Copy link

Is the fix to remove the <-pedantic> flag from the Cmake/build scripts?

@vitaut
Copy link
Contributor

vitaut commented Feb 23, 2021

You can define the FMT_USE_UDL_TEMPLATE to 1 to suppress this particular warning or adjust the check here

fmt/include/fmt/format.h

Lines 151 to 163 in 2797588

#ifndef FMT_USE_UDL_TEMPLATE
// EDG frontend based compilers (icc, nvcc, PGI, etc) and GCC < 6.4 do not
// properly support UDL templates and GCC >= 9 warns about them.
# if FMT_USE_USER_DEFINED_LITERALS && \
(!defined(__EDG_VERSION__) || __EDG_VERSION__ >= 501) && \
((FMT_GCC_VERSION >= 604 && __cplusplus >= 201402L) || \
FMT_CLANG_VERSION >= 304) && \
!defined(__PGI) && !defined(__NVCC__)
# define FMT_USE_UDL_TEMPLATE 1
# else
# define FMT_USE_UDL_TEMPLATE 0
# endif
#endif
and submit a PR =).

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

5 participants