Bug 91786

Summary: Clang 8.0.1 can't compile the <filesystem> header on Windows
Product: gcc Reporter: Egor <iamsupermouse>
Component: libstdc++Assignee: Jonathan Wakely <redi>
Status: RESOLVED FIXED    
Severity: normal CC: webrown.cpp
Priority: P3 Keywords: rejects-valid
Version: 9.2.1   
Target Milestone: 9.3   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2019-11-21 00:00:00

Description Egor 2019-09-16 20:46:17 UTC
On Windows, Clang 8.0.1 refuses to compile the <filesystem> header with following errors:

> In file included from ...\mingw64\include\c++\9.2.0\filesystem:37:
> ...\mingw64\include\c++\9.2.0\bits/fs_path.h:636:31: error: invalid use of incomplete
>       type 'std::filesystem::__cxx11::filesystem_error'
>       _GLIBCXX_THROW_OR_ABORT(filesystem_error(
>                               ^~~~~~~~~~~~~~~~~
> ...\mingw64\include\c++\9.2.0\x86_64-w64-mingw32\bits/c++config.h:177:49: note: expanded
>       from macro '_GLIBCXX_THROW_OR_ABORT'
> #  define _GLIBCXX_THROW_OR_ABORT(_EXC) (throw (_EXC))
>                                                 ^~~~
> ...\mingw64\include\c++\9.2.0\bits/fs_fwd.h:61:9: note: forward declaration of
>       'std::filesystem::__cxx11::filesystem_error'
>   class filesystem_error;
>         ^
> 1 error generated.

We can prevent Clang from complaining by moving the definition of `class filesystem_error` a few lines up. It should be at least above the definition of `u8path()`.
Comment 1 Jonathan Wakely 2019-11-25 19:02:35 UTC
Author: redi
Date: Mon Nov 25 19:01:58 2019
New Revision: 278697

URL: https://gcc.gnu.org/viewcvs?rev=278697&root=gcc&view=rev
Log:
PR libstdc++/91786 fix compilation error with Clang

	PR libstdc++/91786
	* include/bits/fs_path.h (filesystem_error): Move definition before
	the use in u8path.

Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/include/bits/fs_path.h
Comment 2 Jonathan Wakely 2019-12-11 13:46:14 UTC
Fixed for GCC 9.3
Comment 3 Jonathan Wakely 2019-12-11 13:46:28 UTC
Author: redi
Date: Wed Dec 11 13:45:56 2019
New Revision: 279223

URL: https://gcc.gnu.org/viewcvs?rev=279223&root=gcc&view=rev
Log:
PR libstdc++/91786 fix compilation error with Clang

Backport from mainline
2019-11-25  Jonathan Wakely  <jwakely@redhat.com>

	PR libstdc++/91786
	* include/bits/fs_path.h (filesystem_error): Move definition before
	the use in u8path.

Modified:
    branches/gcc-9-branch/libstdc++-v3/ChangeLog
    branches/gcc-9-branch/libstdc++-v3/include/bits/fs_path.h