【问题标题】:What does the gcc warning "coverage_mismatch" mean?gcc 警告“coverage_mismatch”是什么意思?
【发布时间】:2020-04-03 03:47:40
【问题描述】:

今天我在编译一些erlang/opt时遇到Werror=Wcoverage_mismatch错误:

beam/beam_emu.c: In function 'erts_current_reductions':                                                     
beam/beam_emu.c:3150:1: error: the control flow of function 'erts_current_reductions' does not match its profile data (counter 'arcs') [-Werror=coverage-mismatch]             
 } 
...

但我不知道这是什么意思,谷歌没有告诉我关于这个标志的任何信息。 下面是gcc source code

if (entry->n_counts != n_counts)
      warning_printed = warning_at(
          DECL_SOURCE_LOCATION(current_function_decl), OPT_Wcoverage_mismatch,
          "number of counters in profile data for function %qD "
          "does not match "
          "its profile data (counter %qs, expected %i and have %i)",
          current_function_decl, ctr_names[counter], entry->n_counts, n_counts);
    else
      warning_printed = warning_at(
          DECL_SOURCE_LOCATION(current_function_decl), OPT_Wcoverage_mismatch,
          "the control flow of function %qD does not match "
          "its profile data (counter %qs)",
          current_function_decl, ctr_names[counter]);

【问题讨论】:

    标签: c gcc erlang code-coverage cflags


    【解决方案1】:

    请参阅Warning options 上的 GCC (9.2.0) 手册:

    -Wno-coverage-mismatch

    使用-fprofile-use 选项时,如果反馈配置文件不匹配,则会发出警告。如果在使用-fprofile-generate-fprofile-use 编译之间更改了源文件,则带有配置文件反馈的文件可能无法匹配源文件,并且 GCC 无法使用配置文件反馈信息。默认情况下,此警告已启用并被视为错误。 -Wno-coverage-mismatch 可用于禁用警告或-Wno-error=coverage-mismatch 可用于禁用错误。禁用此警告的错误可能会导致代码优化不佳,并且仅在非常小的更改(例如对现有代码库的错误修复)的情况下才有用。不建议完全禁用警告。

    因此,您的源代码似乎自编译后发生了变化,这可能会导致问题(因此出现错误消息)。重新编译并重新运行分析。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-11-02
      • 1970-01-01
      • 2013-08-18
      • 1970-01-01
      • 1970-01-01
      • 2014-04-17
      • 2012-02-02
      • 1970-01-01
      相关资源
      最近更新 更多