Bug 91786 - Clang 8.0.1 can't compile the <filesystem> header on Windows
Summary: Clang 8.0.1 can't compile the <filesystem> header on Windows
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 9.2.1
: P3 normal
Target Milestone: 9.3
Assignee: Jonathan Wakely
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2019-09-16 20:46 UTC by Egor
Modified: 2019-12-11 13:46 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2019-11-21 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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