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

Support suppressing opportunistic compiler warnings #4598

Merged

Conversation

bjorng
Copy link
Contributor

@bjorng bjorng commented Mar 9, 2021

Opportunistic warnings are the warnings that the compiler's optimization and code generating passes emit when they happen to notice potential issues.

One problem with the opportunistic warnings is that there can be inappropriate warnings for perfectly good code, especially if inlining or macros are involved. Therefore, it has been our TO DO list for a long time to implement a way to turn off those warnings.

#4545, which was recently merged, can cause more spurious warnings to appear (because a fun that is now inlined could suppress warnings intentionally or unintentionally). Therefore, it's high time to add options to suppress opportunistic warnings.

disabling all warnings).</p>
<p>Another kind of warnings is <em>opportunistic
warnings</em>. They are generated when the compiler
<strong>happens</strong> to notice potential issues during
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this stress "potential" and not "happens"? Or is it not a given that in some cases e.g. unused returned values would be missed by the compiler?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to emphasize the other kind of problem with opportunistic warnings, namely that not all potential problems are reported. I think it is better to remove the emphasis on "happens".

@bjorng bjorng force-pushed the bjorn/compiler/opportunistic-warnings/OTP-17260 branch 2 times, most recently from 3e71047 to d179bea Compare March 10, 2021 05:07
@bjorng bjorng force-pushed the bjorn/compiler/opportunistic-warnings/OTP-17260 branch 2 times, most recently from 7dae886 to ef0bbb2 Compare March 11, 2021 12:18
bjorng added 2 commits March 12, 2021 06:45
Classify the warnings from the v3_core, sys_core_fold, and
v3_kernel into three different categories:

* {nomatch,Term} - a pattern will not match for some reason.
* {failed,Term} - an expression or term construction will fail for some reason.
* {ignored,Term} - an expression or constructed term is ignored.

The classification will make it easier to selectively disable certain
categories of warnings.
It has never been possible to disable the opportunistic warnings
generated by the code generation and optimization passes.

It is high time to allow the user to disable those warnings,
especially since using funs to suppress warnings may no longer
work since commit 72675ba that introduced inlining of funs
that were immediately used.
@bjorng bjorng force-pushed the bjorn/compiler/opportunistic-warnings/OTP-17260 branch 2 times, most recently from 9cd6d0a to b217b21 Compare March 12, 2021 06:09
@bjorng bjorng merged commit 27622dd into erlang:master Mar 12, 2021
@bjorng bjorng deleted the bjorn/compiler/opportunistic-warnings/OTP-17260 branch March 12, 2021 06:11
michaelklishin added a commit to rabbitmq/rabbitmq-server that referenced this pull request Mar 17, 2021
To work around erlang-lager/lager#546.

The flag was introduced in erlang/otp#4598, which
is more recent than 24-rc.1.
michaelklishin added a commit to rabbitmq/rabbitmq-server that referenced this pull request Apr 8, 2021
To work around erlang-lager/lager#546.

The flag was introduced in erlang/otp#4598, which
is more recent than 24-rc.1.
michaelklishin added a commit to rabbitmq/rabbitmq-server that referenced this pull request Apr 22, 2021
To work around erlang-lager/lager#546.

The flag was introduced in erlang/otp#4598, which
is more recent than 24-rc.1.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement team:VM Assigned to OTP team VM
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants