Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

The filesystem::path::format type is not declared correctly. #51503

Open Quuxplusone opened 3 years ago

Quuxplusone commented 3 years ago
Bugzilla Link PR52536
Status NEW
Importance P normal
Reported by Ed Vogel (edward.vogel@hpe.com)
Reported on 2021-11-17 12:06:45 -0800
Last modified on 2021-11-24 06:16:37 -0800
Version 11.0
Hardware All All
CC joeloser93@gmail.com, llvm-bugs@lists.llvm.org, mclow.lists@gmail.com
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
It seems that libc++ declares filesystem::path::format as a class.   The
standard requires it to be an enum.  This prevents programs from compiling when
-stdlib=libc++ is used.  Here is a cut/paste from a cygwin session:

$ cat t.cpp
#include <filesystem>
#include <type_traits>
using namespace std;

int main(void)
{
  typedef enum filesystem::path::format T1;
  typedef std::underlying_type<T1>::type T2;
  T1 a;
  T2 b;
  b = a;
}

VogelEd@XLB3502Q4E ~/tests/cppperen2.0
$ clang++ -std=c++17 t.cpp

VogelEd@XLB3502Q4E ~/tests/cppperen2.0
$ clang++ -std=c++17 -stdlib=libc++ t.cpp
t.cpp:11:7: error: assigning to 'T2' (aka 'unsigned char') from incompatible
      type 'T1' (aka 'std::__1::__fs::filesystem::path::format')
  b = a;
      ^
1 error generated.

Visual Studio 2019 also compiles the program.

The (V11) version of filesystem contains:

  enum class _LIBCPP_ENUM_VIS format : unsigned char {
    auto_format,
    native_format,
    generic_format
  };

It seems g++ gets this right.  They have:

    enum format : unsigned char { native_format, generic_format, auto_format };

Not a significant problem, but I wanted to make you aware of it.

Thanks,

Ed Vogel
Quuxplusone commented 3 years ago

Can you share some more info, please? std::filesystem::path::format is indeed an enum - see https://github.com/llvm/llvm-project/blob/6889592ebcdea168f9e7a5dc91b8549527e4dbf7/libcxx/include/filesystem#L942.

Quuxplusone commented 3 years ago

Argh...sorry, I forgot to check your latest sources. I am using V11, and the definition there is wrong. This does seem to be corrected in V13.

Please close this.

Again...sorry to have bothered you.

I will try to remember to check the latest release from now on...

Ed