New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug fixing #1151
base: dmitrykobets-msft/experiment/fix-span-2020-gtest-failures
Are you sure you want to change the base?
Bug fixing #1151
Conversation
* Fix C++20 bugs and tests * Rework CI for C++2020 tests * Update readme compiler versions
Bump clang and Xcode supported versions and add support for VS with LLVM
[SF.12: Prefer the quoted form of #include for files relative to the including file and the angle bracket form everywhere else](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Rs-incform) Additionally changed #include order in `span` so that all `span_ext` is in the GSL include block and not in the STL include block. Fixes issues microsoft#1025. Co-authored-by: Werner Henze <w.henze@avm.de>
The following reserved identifiers are being used specifically to target certain MSVC constructs, so suppress the warning in VS 2022 (LLVM) "... is reserved because it starts with '_' followed by a capital letter": - _Unchecked_type - _Verify_range - _Verify_offset - _Unwrapped - _Unwrap_when_unverified - _Seek_to - _Unchecked_begin - _Unchecked_end
…soft#1035) Resolves microsoft#1016 Co-authored-by: Casey Carter <Casey@Carter.net>
…osoft#1043) In the implementation of gsl::narrow, there is a comparison `static_cast<U>(t) != u` which may be comparing two floats. The comparison here is done purposefully to categorize ill effects of narrowing conversion, since the values being compared *should* be the same when compared with `operator==`. Note, using #pragma GCC will suppress this warning for both GCC and Clang.
This file uses std::exception, so it should include the appropriate header. Normally it gets the STL's <exception> header included via the gsl/assert file, but this is skipped with _HAS_EXCEPTIONS=0. I understand _HAS_EXCEPTIONS is undocumented and unsupported, but regardless, the appropriate header should be included here. Alternatively, gsl/narrow should be modified to support _HAS_EXCEPTIONS=0, like gsl/assert was. But I'm not proposing that change. <exception> does define std::exception even with _HAS_EXCEPTIONS=0.
As per the CoreGuidelines, gsl::narrow is defined in terms of static_cast. Suppress es.46, which suggests converting the static_cast into gsl::narrow
Both checks for Expects(ExtentType::size() != dynamic_extent); in storage_type are always useless. storage_type<ExtentType> is only ever created with ExtentType == extent_type<Extent>, where Extent has type std::size_t and is the extent of the span. Looking at extent_type<std::size_t Ext>::size(): - if Ext != dynamic_extent, then size() always returns Ext, and therefore size() != dynamic_extent - if Ext == dynamic_extent, then size() returns extent_type<dynamic_extent>::size_. size_ can only be set via one of two constructors: - constexpr explicit extent_type(size_type size), which already does the check in question - constexpr explicit extent_type(extent_type<Other> ext) : size_(ext.size()), which simply relies on the other extent's size() method So there is no way for ExtentType::size() == dynamic_extent.
Co-authored-by: microsoft-github-policy-service[bot] <77245923+microsoft-github-policy-service[bot]@users.noreply.github.com>
* Test solution * Mark dynamic_extent as inline, compiler-version-permitting
actions/runner-images#5930 recently updated the NDK version, resulting in test breakages. Update the version.
GCC 4.8.0 - 7.0 has a bug (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480) involving specialization in a namespace enclosing the specialized template. This PR fixes an appearance of this bug in the span header.
This PR future-proofs the fix made in microsoft#1053, which is now outdated due to further updates to the NDK version in the Azure VMs used as part of the CI.
These warnings were found by running clang-tidy 15.
Somewhere along the way, GSL's implementation of final_act and finally seems to have become way overthought. This PR is to re-simplify these facilities back to what C++ Core Guidelines C.30 said which is simple and clear and works. It just copies the invocable thing, and doesn't bother trying to optimize the copy. This should be fine, because we're typically passing something that's cheap to copy, often a stateless lambda. The problem in microsoft#846 appears to be because finally looks like was originally written as a const&/&& overload (its state at the time that issue was opened)... to eliminate a copy when you invoke it with a temporary. If so, then the && was probably never intended to be a forwarder, but an rvalue reference that tripped over the horrid C++ syntax collision where a && parameter magically instead means a forwarding reference because the type happens to be a template parameter type here. So I suspect the original author was just trying to write an rvalue overload, and the forwarder that's there now was never intended at all.
Closes issue microsoft#550, which highlighted overhead in not_null::get for larger types such as shared_ptr. Every call to get would return a copy of the contained value. This PR implements Herb's suggestion for changing the return type of not_null::get. The not_null's value will now only be copied if it is "trivially copyable"; otherwise, it will be returned by const reference. Note: this change also forces the returned copy to be const.
- Move all install logic inside gsl_install.cmake - This makes reading the logic easier, and avoids the enable language issue with `GNUInstallDirs` by having it included after the project call - Have all functions inside gsl_functions.cmake - Use CMake idiom PROJECT_IS_TOP_LEVEL - Update README.md
This avoids propagating -std=c++14 as a compile option Currently if you use less than CMake 3.8 and you install the project `-std=c++14` gets added to the INTERFACE_COMPILE_OPTIONS. This forces users to use C++ 14 or remove the property from the imported target. The solution is to raise the minimum and use `cxx_std_14`
I ran GSL through clang-tidy with the performance-* checks https://releases.llvm.org/15.0.0/tools/clang/tools/extra/docs/clang-tidy/checks/performance/noexcept-move-constructor.html
The Clang compiler for MSVC in Visual Studio 2022 17.4.33122.133 used by the test runner has a bug which raises -Wdeprecated "out-of-line definition of constexpr static data member is redundant in C++17 and is deprecated" in gsl/span, when compiling with C++14. Temporarily suppress this warning for MSVC Clang with C++14.
Guidelines issue 2006 removes the null check inside not_null::get, since the contained pointer is already guaranteed to be not-null upon construction. Resolves microsoft#1051
NaN != Nan, so the comparisons used in gsl::narrow will always throw when attempting to cast a NaN value. This may be surprising, so document it.
This solves issue microsoft#1070 and removes the class `string_span`. The only content remaining in the header file `gsl/string_span` is the `*zstring` types. This also removes the `string_span_tests.cpp` unit tests as these were only for the deprecated `string_span` class. Co-authored-by: Werner Henze <werner.henze+gitcommits@posteo.de>
The `#i13-do-not-pass-an-array-as-a-single-pointer` anchor seems to be auto generated based on the title of the section. The `#Ri-array` anchor is explicitely written in the source, so this should be a better link.
`<gsl/span>` is intended to mirror `<span>` in the STL. `<span_ext>` provides convenience features that aren't part of `<span>`. Address microsoft#1095
- Capitalize inital letter (make both tables consistent) - Add links to docs/headers.md - Latest cmake requirement is 3.14 - Mark text as code
Suppress "warning C26481: Don't use pointer arithmetic. Use span instead (bounds.1)." in the code that impements `span`.
`size_bytes()` returns the span's size in bytes. Assuming the span was constructed with an accurate size parameter, the check `size() < dynamic_extent / sizeof(element_type)` isn't required, since `size_t(-1)` (which is `dynamic_extent`) represents the size of the address space, so the number of bytes will never exceed it and in practice won't even come close. Otherwise, it is not actually feasible to detect cases when the size parameter does not correspond to the dimensions of the underlying data pointer. In these cases, the relationship `size() < dynamic_extent / sizeof(element_type)` is simply one of many ways in which the `size()` could be incorrect, and serves no necessary purpose. Resolves microsoft#1012
…sons with `not_null` (microsoft#1106) Using `<`,`<=`,`>`,`>=` to compare unrelated pointers gives an unspecified result according to the standard. This PR replaces the usage of these operators in `gsl::not_null` with the STL counterparts, which would leverage any implementation-defined strict total ordering for pointers. Resolves microsoft#880
Turns out supporting GSL.natvis perfectly is quite difficult. There is no universal way to consume .natvis files that would satisfy everyone. I thought the solution was to use the /NATVIS linker option. But it turns out that actually embeds information into the PDB. So I'm not sure how to properly support the Ninja generator... That's not even accounting for the fact target_link_options doesn't play nicely with /NATVIS When you just add the file via target_sources the visual studio solution will just pick it up and recognize it without adding it to the PDB file. Which won't affect the binary and is what most devs want. This all comes down to the fact that /NATVIS files have native integration with visual studio that makes it difficult to use with non-visual studio solutions. /NATVIS almost works but embeds itself into the PDB which not everyone wants, and not everyone generates PDBs either. Docs for natvis files and /NATVIS - https://learn.microsoft.com/en-us/visualstudio/debugger/create-custom-views-of-native-objects?view=vs-2022 - https://learn.microsoft.com/en-us/cpp/build/reference/natvis-add-natvis-to-pdb?view=msvc-170 So my current solution is to just simplify the existing CMake code, and install the natvis so the user can decide. closes microsoft#1084
These overloads don't seem to be in a usable state, and their original purpose is no longer clear. Deprecate them. Resolves microsoft#1092
Headers that were previously prefixed with `gsl_` were renamed to drop the `gsl_` prefix in microsoft#946, and the original version deprecated. The deprecation happened a long time ago, so it is now time to remove these headers entirely.
…soft#1125) With `string_span` having been deprecated (microsoft#931, microsoft#945) and removed (microsoft#1074), the header `<gsl/string_span>` now only contains the definitions for the `zstring` family. Update the name accordingly from `<gsl/string_span>` to `<gsl/zstring>`. The old header is now deprecated and should no longer be used and will be removed in some future release.
Without this change a `gsl::not_null<class_type>` triggers these `noexcept` warnings: ``` .../gsl/include/gsl/pointers:162:50: warning: noexcept-expression evaluates to ‘false’ because of a call to ‘constexpr gsl::details::value_or_reference_return_t<T> gsl::not_null<T>::get() const [with T = class_type*; gsl::details::value_or_reference_return_t<T> = class_type* const]’ [-Wnoexcept] 162 | const not_null<U>& rhs) noexcept(noexcept(lhs.get() == rhs.get())) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .../gsl/include/gsl/pointers:119:55: note: but ‘constexpr gsl::details::value_or_reference_return_t<T> gsl::not_null<T>::get() const [with T = class_type*; gsl::details::value_or_reference_return_t<T> = class_type* const]’ does not throw; perhaps it should be declared ‘noexcept’ 119 | constexpr details::value_or_reference_return_t<T> get() const | ^~~ ``` Co-authored-by: Werner Henze <w.henze@avm.de>
The header file uses `std::declval`, so it needs to `#include <utility>`.
Before my PR microsoft#1122 `gsl/pointers` was gcc 8.4 compatible. Now it is not. This commit makes it compatible with gcc 8.4 again.
This macro is a relic of the old implementation of GSL's header. It is unused and can be removed.
- Add anchor for `finally` in `headers.md` so that the link in `README.md` can work - In `README.md` add code formatting for the character types of the `zstring` and `string_span` types - In `README.md` change code formatting to links for GSL types - Vertical alignment
Two warnings were being emitted in the MSVC+LLVM tests. The warning `-Wunsafe-buffer-usage` is initially introduced in some capacity here https://reviews.llvm.org/D137346 pointing to documentation at https://discourse.llvm.org/t/rfc-c-buffer-hardening/65734. The warning is a stylistic checker whose goal is to "emit a warning every time an unsafe operation is performed on a raw pointer". This type of programming model is not useful for library implementations of types such as `span`, where direct manipulation of raw pointers is inevitable, so disable the warning altogether. There is also a false-positive warning llvm/llvm-project#65689 that I've disabled inline.
…ed string literal. (microsoft#1133) Fix microsoft#1130.
…ved with no exception (microsoft#1135) This enables possible optimisations for trivial types. This also avoids a bug in std::variant::emplace from GNU's libstdc++. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106547
This fixes annotations on task runs like the following: The following actions uses node12 which is deprecated and will be forced to run on node16: actions/checkout@v2. For more info: https://github.blog/changelog/2023-06-13-github-actions-all-actions-will-run-on-node16-instead-of-node12-by-default/
* Suppress unsafe-buffer-usage
Co-authored-by: Werner Henze <w.henze@avm.de>
@CEEANPROJEC please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
|
Application-bundle-Java.zip