u8pathstd::string deprecation with libc++ and c++20 #24682

issue Sjors openend this issue on March 26, 2022
  1. Sjors commented at 9:25 am on March 26, 2022: member

    When trying to compile with c++20 support (added in #24169) on macOS 12.3 on master I get inundated with the below warning.

    0 ./configure --enable-c++20 --enable-suppress-external-warnings
    
     0In file included from bitcoin-cli.cpp:19:
     1In file included from ./util/system.h:20:
     2./fs.h:71:29: warning: 'u8path<std::string>' is deprecated [-Wdeprecated-declarations]
     3    return std::filesystem::u8path(utf8_str);
     4                            ^
     5/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/filesystem:1570:27: note: 'u8path<std::string>' has been explicitly marked deprecated here
     6_LIBCPP_INLINE_VISIBILITY _LIBCPP_DEPRECATED_WITH_CHAR8_T
     7                          ^
     8/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__config:1078:43: note: expanded from macro '_LIBCPP_DEPRECATED_WITH_CHAR8_T'
     9#  define _LIBCPP_DEPRECATED_WITH_CHAR8_T _LIBCPP_DEPRECATED
    10                                          ^
    11/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__config:1043:48: note: expanded from macro '_LIBCPP_DEPRECATED'
    12#    define _LIBCPP_DEPRECATED __attribute__ ((deprecated))
    13                                               ^
    141 warning generated.
    
  2. Sjors added the label Bug on Mar 26, 2022
  3. MarcoFalke commented at 9:43 am on March 26, 2022: member

    On Windows there is _SILENCE_CXX20_U8PATH_DEPRECATION_WARNING, maybe something similar exists for macOS?

    An alternative would be to copy the string into a std::u8string first: return std::filesystem::u8path(std::u8string{utf8_str.begin(), utf8_str.end()}); (obviously guarded by C++20)

  4. bitcoin deleted a comment on Mar 27, 2022
  5. laanwj commented at 12:59 pm on April 5, 2022: member
    0#define string u8string
    

    :sweat_smile:

  6. fanquake removed the label Bug on Aug 8, 2022
  7. fanquake renamed this:
    u8path<std::string> deprecation on macOS with c++20
    u8path<std::string> deprecation with libc++ and c++20
    on Aug 8, 2022
  8. fanquake commented at 4:03 pm on August 8, 2022: member

    This isn’t macOS specific or a bug, so I’ve updated the title and labels. It’s going to occur when using c++20 and libc++, and does so building with Clang and libc++ on Linux. i.e:

    0clang --version
    1Ubuntu clang version 14.0.0-1ubuntu1
    2Target: x86_64-pc-linux-gnu
    3Thread model: posix
    4InstalledDir: /usr/bin
    
     0./autogen.sh
     1CC='clang' CXX='clang++ -stdlib=libc++' ./configure --enable-c++20
     2make
     3...
     4  CXX      bitcoind-bitcoind.o
     5In file included from bitcoind.cpp:14:
     6In file included from ./interfaces/chain.h:9:
     7In file included from ./util/settings.h:8:
     8./fs.h:72:29: warning: 'u8path<std::string>' is deprecated [-Wdeprecated-declarations]
     9    return std::filesystem::u8path(utf8_str);
    10                            ^
    11/usr/lib/llvm-14/bin/../include/c++/v1/__filesystem/u8path.h:72:27: note: 'u8path<std::string>' has been explicitly marked deprecated here
    12_LIBCPP_INLINE_VISIBILITY _LIBCPP_DEPRECATED_WITH_CHAR8_T
    13                          ^
    14/usr/lib/llvm-14/bin/../include/c++/v1/__config:1042:43: note: expanded from macro '_LIBCPP_DEPRECATED_WITH_CHAR8_T'
    15#  define _LIBCPP_DEPRECATED_WITH_CHAR8_T _LIBCPP_DEPRECATED
    16                                          ^
    17/usr/lib/llvm-14/bin/../include/c++/v1/__config:1007:48: note: expanded from macro '_LIBCPP_DEPRECATED'
    18#    define _LIBCPP_DEPRECATED __attribute__ ((deprecated))
    19                                               ^
    201 warning generated.
    

    We could suppress all deprecated-declaration warnings when building with c++20, but that’d be overkill. We can probably just pragma around the single instance in our code we want to suppress, and let any other deprecation warnings bubble up.

  9. fanquake referenced this in commit 68b615e768 on Aug 8, 2022
  10. fanquake referenced this in commit b7ca628b00 on Aug 8, 2022
  11. fanquake referenced this in commit e131f0c465 on Aug 9, 2022
  12. fanquake referenced this in commit 6bf6234790 on Aug 9, 2022
  13. fanquake referenced this in commit ced00f5a2e on Aug 19, 2022
  14. MarcoFalke referenced this in commit d480586ecb on Aug 19, 2022
  15. MarcoFalke closed this on Aug 19, 2022

  16. sidhujag referenced this in commit 241e31f319 on Aug 19, 2022
  17. Rspigler referenced this in commit 7a1e140dfa on Aug 21, 2022
  18. bitcoin locked this on Aug 19, 2023

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-11-17 21:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me