Skip to content
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

<yvals_core.h>: _EMIT_STL_ERROR leads to uninformative error logs #4009

Closed
StephanTLavavej opened this issue Sep 5, 2023 · 2 comments · Fixed by #4020
Closed

<yvals_core.h>: _EMIT_STL_ERROR leads to uninformative error logs #4009

StephanTLavavej opened this issue Sep 5, 2023 · 2 comments · Fixed by #4020
Labels
enhancement Something can be improved fixed Something works now, yay!

Comments

@StephanTLavavej
Copy link
Member

#2897 introduced:

STL/stl/inc/yvals_core.h

Lines 512 to 514 in 6c69a73

#define _EMIT_STL_ERROR(NUMBER, MESSAGE) \
_EMIT_STL_MESSAGE("error " #NUMBER ": " MESSAGE) \
static_assert(false, "Error in C++ Standard Library usage.")

This emits a #pragma message which is captured in full build logs but not error-only logs, followed by a static_assert which does appear in error-only logs but with a message that doesn't say what's actually wrong.

This has the potential to confuse users who are looking at error-only logs; e.g. in twistedfall/opencv-rust#452 the problem was very simple (Clang version was too old), but the static_assert lost the reason.

For _EMIT_STL_ERROR, I think we should use static_assert alone (with the given NUMBER and MESSAGE); I don't see any reason to use #pragma message here.

@StephanTLavavej StephanTLavavej added the enhancement Something can be improved label Sep 5, 2023
@frederick-vs-ja
Copy link
Contributor

STL/stl/inc/yvals_core.h

Lines 509 to 511 in 6c69a73

#define _EMIT_STL_WARNING(NUMBER, MESSAGE) \
_EMIT_STL_MESSAGE("warning " #NUMBER ": " MESSAGE) \
static_assert(true, "")

Maybe related: can/should we remove the seemingly useless static_assert from _EMIT_STL_WARNING?

@frederick-vs-ja
Copy link
Contributor

I found that #pragma message has its own benefit:

  • it doesn't emit unhelpful error codes (C1189 for #error or C2338 for static_assert);
  • it can cause Visual Studio to generate a link in Error List - however, the generated links are currently invalid.

But it can't be used for rejecting an invalid program.

Error diagnostics have some drawbacks:

  • currently, static_assert doesn't prevent MSVC emitting following error messages;
  • #error prevents MSVC emitting following error messages, but stringization doesn't take place within it; and
  • both of them emit unhelpful error codes.

Ideally, there should be something behaving like #pragma message except that it terminates compilation after emitting the error message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Something can be improved fixed Something works now, yay!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants