[PATCH] D130894: [clang] Print more information about failed static assertions

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 5 05:34:49 PDT 2022


aaron.ballman added reviewers: erichkeane, cjdb, clang-language-wg, jyknight.
aaron.ballman added a comment.

In D130894#3701749 <https://reviews.llvm.org/D130894#3701749>, @tbaeder wrote:

> For the record, the output now looks something like this:
>
>   test.cpp:24:1: error: static assertion failed due to requirement 'c != c'
>   static_assert(c != c);
>   ^             ~~~~~~
>   test.cpp:24:17: note: expression evaluates to '('0' != '0')'
>   static_assert(c != c);
>                 ~~^~~~

This looks hard to read to me...

> test.cpp:25:1: error: static assertion failed due to requirement 'c > 'a''
> static_assert(c > 'a');
> ^             ~~~~~~~
> test.cpp:25:17: note: expression evaluates to '('0' > 'a')'

Same confusion here -- it took me a while to realize what's happening is that we're quoting the part outside of the parens and that's throwing me for a loop. We typically quote things that are syntax but in this case, the parens are not part of the syntax and so the surrounding quotes are catching me. Given that parens are being used as a visual delimiter and a single quote serves the same purpose, I would expect something more like:

  test.cpp:25:17: note: expression evaluates to ''0' > 'a''
  test.cpp:26:17: note: expression evaluates to '0 > 'a''
  test.cpp:27:17: note: expression evaluates to '14 > 5'
  test.cpp:28:17: note: expression evaluates to 'true == false'
  test.cpp:29:17: note: expression evaluates to 'nullptr != nullptr'

Adding a few more folks as reviewers to see if there is a consensus position on how to proceed.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D130894/new/

https://reviews.llvm.org/D130894



More information about the cfe-commits mailing list