C++ 宇宙飞船操作员的叮当声分析错误

C++ 宇宙飞船操作员的叮当声分析错误,c++,clang,c++20,clang-tidy,C++,Clang,C++20,Clang Tidy,使用clang++-11withlibstdc++-11和clang-tidy-11,我在使用clang-tidy对代码进行lint时遇到了故障,即在处理著名的睡眠者std::this_thread::sleep_for(std::chrono::seconds(1)) clang-tidy-11-header filter=include/-p=/tmp/dev/build/bin/aggregation/-quiet/tmp/de v/build/aggregation/src/main.c

使用
clang++-11
with
libstdc++-11
clang-tidy-11
,我在使用
clang-tidy
对代码进行lint时遇到了故障,即在处理著名的睡眠者
std::this_thread::sleep_for(std::chrono::seconds(1))

clang-tidy-11-header filter=include/-p=/tmp/dev/build/bin/aggregation/-quiet/tmp/de
v/build/aggregation/src/main.cc
请将错误报告提交给https://bugs.llvm.org/ 并包括崩溃回溯。
堆栈转储:
0程序参数:clang-tidy-11-header filter=include/-p=/tmp/dev/build/bin/
聚合/-quiet/tmp/dev/build/aggregation/src/main.cc
1.文件末尾的解析器
2.分析堆栈时:
#0在/usr/include/c++/11/thread:125:6行调用std::chrono::operator
#1在第159行调用std::this_线程::sleep_
#2主叫
3.      /usr/include/c++/11/chrono:771:9:错误求值语句
4.      /usr/include/c++/11/chrono:771:9:错误求值语句
/usr/lib/x86_64-linux-gnu/libLLVM-11.so.1(_ZN4llvm3sys15PrintStackTraceERNS_11raw_ostre
amE+0x1f)[0x7f4ae7718e7f]
/usr/lib/x86_64-linux-gnu/libLLVM-11.so.1(_ZN4llvm3sys17RunSignalHandlersEv+0x50)[0x7f4
ae77171e0]
/usr/lib/x86_64-linux-gnu/libLLVM-11.so.1(+0xbd1355)[0x7f4ae7719355]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x14140)[0x7f4aee8ec140]
/usr/lib/x86_64-linux-gnu/libclang cpp.so.11(_zn5clang4ento17基本价值工厂25getpers
istentSValWithDataERKNS0_4SValEm+0x58)[0x7f4aedd82e38]
我检查了一下它是否可以用

#包括
结构IntWrapper{
int值;
constexpr IntWrapper(int值):值{value}{}
自动运算符(const-IntWrapper&)const=default;
};
constexpr bool是(const-IntWrapper&a、const-IntWrapper&b){
返回a
失败似乎发生在

模板
需要三路可比
康斯特普汽车公司
操作员(常数持续时间和时间),
常数持续时间(右)
{
使用uuu ct=普通类型u t;
返回uu-ct(u-lhs).count()u-ct(u-rhs).count();
}
我通过使用
boost::this_thread::sleep_for(boost::chrono::seconds(1))的临时解决方法(suure)克服了这个问题

你有什么建议吗?我是否在某个地方失败了,或者它是clang tidy中众所周知的错误,我应该毫不犹豫地提交错误报告?

确认了clang tidy错误。我将保留这个问题,也许有人会发现
boost
技巧在修复之前很有用。

您可以使用(now()+1s)作为参数的方法。

清除clang tidy bug。它可以通过clang tidy检查,但不会崩溃。这确实是一个很好的解决办法。
clang-tidy-11 -header-filter=include/ -p=/tmp/dev/build/bin/aggregation/ -quiet /tmp/de
v/build/aggregation/src/main.cc
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace.
Stack dump:
0.      Program arguments: clang-tidy-11 -header-filter=include/ -p=/tmp/dev/build/bin/
aggregation/ -quiet /tmp/dev/build/aggregation/src/main.cc
1.      <eof> parser at end of file
2.      While analyzing stack:
        #0 Calling std::chrono::operator<=> at line /usr/include/c++/11/thread:125:6
        #1 Calling std::this_thread::sleep_for at line 159
        #2 Calling main
3.      /usr/include/c++/11/chrono:771:9: Error evaluating statement
4.      /usr/include/c++/11/chrono:771:9: Error evaluating statement
/usr/lib/x86_64-linux-gnu/libLLVM-11.so.1(_ZN4llvm3sys15PrintStackTraceERNS_11raw_ostre
amE+0x1f)[0x7f4ae7718e7f]
/usr/lib/x86_64-linux-gnu/libLLVM-11.so.1(_ZN4llvm3sys17RunSignalHandlersEv+0x50)[0x7f4
ae77171e0]
/usr/lib/x86_64-linux-gnu/libLLVM-11.so.1(+0xbd1355)[0x7f4ae7719355]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x14140)[0x7f4aee8ec140]
/usr/lib/x86_64-linux-gnu/libclang-cpp.so.11(_ZN5clang4ento17BasicValueFactory25getPers
istentSValWithDataERKNS0_4SValEm+0x58)[0x7f4aedd82e38]
#include <compare>
struct IntWrapper {
  int value;
  constexpr IntWrapper(int value): value{value} { }
  auto operator<=>(const IntWrapper&) const = default;
};

constexpr bool is_lt(const IntWrapper& a, const IntWrapper& b) {
  return a < b;
}
int main() {
  static_assert(is_lt(0, 1));
}
    template<typename _Rep1, typename _Period1,
         typename _Rep2, typename _Period2>
      requires three_way_comparable<common_type_t<_Rep1, _Rep2>>
      constexpr auto
      operator<=>(const duration<_Rep1, _Period1>& __lhs,
          const duration<_Rep2, _Period2>& __rhs)
      {
    using __ct = common_type_t<duration<_Rep1, _Period1>,
                   duration<_Rep2, _Period2>>;
    return __ct(__lhs).count() <=> __ct(__rhs).count();
      }