Source location relative test #3943
-
We have found an issue with source_location where line numbers were reported wrong (https://developercommunity.visualstudio.com/t/std::source_location-started-reporting-w/10429484?q=source_location) It is as below: const auto x = source_location::current();
assert(x.line() == __LINE__ - 1); It is relatively testing against the |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Agreed that static line numbers can be useful, but IMO they should be part of compiler tests. The library doesn't need to detect bugs with |
Beta Was this translation helpful? Give feedback.
-
I dont have a very strong opinion but I could catch the issue in my unit test which was checking a static line number. At least an additional static_assert may be beneficial. But I also agree compiler tests should definitely catch any regression. |
Beta Was this translation helpful? Give feedback.
-
The preprocessor lives at a different "level" than |
Beta Was this translation helpful? Give feedback.
The preprocessor lives at a different "level" than
source_location
, so I think that this is fine for a library test.