This is an archive of the discontinued LLVM Phabricator instance.

Fix libcxx MSVC C++17 redefinition of 'align_val_t'
ClosedPublic

Authored by fcharlie on Jan 21 2018, 8:34 AM.

Details

Summary

When use

clang-cl -std:c++17 -Iinclude\c++\v1 hello.cc c++.lib

An error occurred:

In file included from hello.cc:1:
In file included from include\c++\v1\iostream:38:
In file included from include\c++\v1\ios:216:
In file included from include\c++\v1\__locale:15:
In file included from include\c++\v1\string:477:
In file included from include\c++\v1\string_view:176:
In file included from include\c++\v1\__string:56:
In file included from include\c++\v1\algorithm:643:
In file included from include\c++\v1\memory:656:
include\c++\v1\new(165,29):  error: redefinition of 'align_val_t'
enum class _LIBCPP_ENUM_VIS align_val_t : size_t { };
                            ^
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.12.25827\include\vcruntime_new.h(43,16):  note:
      previous definition is here
    enum class align_val_t : size_t {};
               ^
1 error generated.

vcruntime_new.h has defined align_val_t, libcxx need hide align_val_t.

Diff Detail

Event Timeline

fcharlie created this revision.Jan 21 2018, 8:34 AM
fcharlie edited the summary of this revision. (Show Details)Jan 21 2018, 5:08 PM
fcharlie edited the summary of this revision. (Show Details)
fcharlie added a reviewer: STL_MSFT.
fcharlie updated this revision to Diff 130871.Jan 22 2018, 5:54 AM
fcharlie set the repository for this revision to rCXX libc++.Jan 22 2018, 5:58 AM

Seems reasonable to me.

Seems reasonable to me.

Thanks

mclow.lists added a comment.EditedJan 25 2018, 6:55 PM

I'm pretty sure I don't want to know what MSFT is doing putting align_val_t in *that* header file.

Now I'm wondering if those values __zero and __max are actually used.

fcharlie added a comment.EditedJan 25 2018, 10:18 PM

I'm pretty sure I don't want to know what MSFT is doing putting align_val_t in *that* header file.

Now I'm wondering if those values __zero and __max are actually used.

Use

grep "__zero" -Rn .

There's no place to use __zero and __max. only C++03

This comment was removed by fcharlie.
compnerd accepted this revision.Jan 27 2018, 5:44 PM

I think that if we can remove the __zero and __max, we should do that, but that is better done as a separate change.

This revision is now accepted and ready to land.Jan 27 2018, 5:44 PM
fcharlie accepted this revision.Jan 28 2018, 4:55 AM
This comment was removed by fcharlie.
fcharlie resigned from this revision.Jan 28 2018, 4:58 AM

@compnerd Please commit this, Thanks

EricWF closed this revision.Feb 11 2018, 2:02 PM

Committed as r324853.