This is an archive of the discontinued LLVM Phabricator instance.

[libc++] Remove invalid use of `#if _LIBCPP_STD_VER >= 11`, as `_LIBCPP_STD_VER` can never be less than 11.
ClosedPublic

Authored by curdeius on Dec 10 2020, 4:47 AM.

Details

Summary

The relevant part of __config is:

#ifndef _LIBCPP_STD_VER
#  if  __cplusplus <= 201103L
#    define _LIBCPP_STD_VER 11

Diff Detail

Event Timeline

curdeius requested review of this revision.Dec 10 2020, 4:47 AM
curdeius created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptDec 10 2020, 4:47 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript
curdeius edited the summary of this revision. (Show Details)Dec 10 2020, 4:58 AM
curdeius updated this revision to Diff 310874.Dec 10 2020, 6:37 AM

Remove unnecessary #if altogether.

if you need to remove something for C++03, then the test would be:
#ifndef _LIBCPP_CXX03_LANG

curdeius retitled this revision from [libc++] Fix invalid use of `_LIBCPP_STD_VER >= 11`, as `_LIBCPP_STD_VER` can never be less than 11. to [libc++] Remove invalid use of `#if _LIBCPP_STD_VER >= 11`, as `_LIBCPP_STD_VER` can never be less than 11..Dec 10 2020, 6:42 AM
curdeius planned changes to this revision.Dec 10 2020, 6:46 AM

if you need to remove something for C++03, then the test would be:
#ifndef _LIBCPP_CXX03_LANG

That's exactly what I did in the first try. Please see diff https://reviews.llvm.org/D93025?id=310846.
But as one might have expected, there were tests already that depended on this (incorrect #if).
I'm still thinking what the best course of action should be.

Actually, the choices are:

  1. keep the status quo, it means that there will be an #if that is equivalent to #if 1 and is very misleading
  2. remove this #if altogether (diff no. 2)
  3. change to #ifndef _LIBCPP_CXX03_LANG and fix the tests that fail (that's what I'm trying to do)

This has been introduced in D68480. @__simt__, what was the idea behind this #if _LIBCPP_STD_VER >= 11?
There are other parts that use __cxx_atomic_wait but are not guarded on pre-C++11. Cf. lines 1668, 1670 and 2524, 2527.

I'm drawing a blank. Proceed.

ldionne accepted this revision.Dec 10 2020, 10:15 AM
This revision was not accepted when it landed; it landed in state Changes Planned.Dec 10 2020, 11:32 PM
This revision was automatically updated to reflect the committed changes.