This is an archive of the discontinued LLVM Phabricator instance.

[libcxx] Portability fix: add missing includes and static_casts.
AcceptedPublic

Authored by amakc11 on Dec 17 2018, 10:42 AM.

Details

Summary

This patch fixes the following portability issues in the tests.

Issue 1. Some tests use entitites defined in the standard header files, but do not include these headers directly. As a result, these tests do not compile under some conformant implementations.

Issue 2. Types wctrans_t and wctype_t are required to be scalar (ISO/IEC 9899:1999, section 7.25.1). Type std::ios_base::fmtflags is required to be bitmask (see standard requirement). Neither of these types is required to be integer, and therefore can be implemented, for example, as enum. As a result, any assignment of an integer value to variables of these types without an explicit cast does not compile under some conformant implementations.

Diff Detail

Repository
rCXX libc++

Event Timeline

amakc11 created this revision.Dec 17 2018, 10:42 AM
mclow.lists accepted this revision.Dec 18 2018, 7:44 AM

The includes look fine. The static_casts (as always) look ugly. Once you make the changes that I've requested, you can commit this.

test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_long.pass.cpp
114

Don't repeat this over and over.
Declare a const std::ios_base::fmtflags and initialize it once.

test/std/strings/c.strings/cwctype.pass.cpp
95

This is really ugly. I find it hard to believe that any implementation would force this on it's users.

In any case, we don't actually need to initialize these variables at all.
Really, this test should be rewritten to use ASSERT_SAME_TYPE and declval

Just drop this change from the patch, and I'll fix up this test myself.

This revision is now accepted and ready to land.Dec 18 2018, 7:44 AM
amakc11 updated this revision to Diff 178724.Dec 18 2018, 10:28 AM

The includes look fine. The static_casts (as always) look ugly. Once you make the changes that I've requested, you can commit this.

The requested changes applied. I can't commit the patch myself: I don't have rights to do this.

I can't commit the patch myself: I don't have rights to do this.

Ok; I'll do it.

Did you run these tests after adding the includes?
The "poisoned hash" tests fail - because poisoned_hash_helper.hpp now includes various hash specializations.
In fact, it causes clang to crash (I've reported PR 40093 for that).
I'll remove the changes to "poisoned_hash_helper.hpp" and see what happens.

Committed all of this except "poisoned_hash_helper.hpp" as revision 349566

I don't use clang. The log of running tests including poisoned_hash_helper.hpp is attached.

I don't use clang. The log of running tests including poisoned_hash_helper.hpp is attached.

Please start running the test suite with Clang before submitting patches here. Every single time you submit a patch, it doesn't build for me or one of the other maintainers -- that doesn't work.

Don't get me wrong -- I strongly appreciate you cleaning up the test suite, however contributing patches that don't work on the main implementation used to run the test suite is not a viable way forward.

With respect to this particular patch, I would rather wait for the final verdict on the Clang bug Marshall reported recently. If it is a real bug in compiler, than the patch should be considered as both a portability fix and a bug catcher.