Ticket #1292 (closed bug: fixed)

Opened 6 years ago

Last modified 5 years ago

-Wall doesn't include all warnings

Reported by: guest Owned by:
Priority: normal Milestone:
Component: Compiler Version: 6.7
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

Why is the monomorphism restricion warning different from other warning? I think it should have a -W flag.

Furthermore, having this flag on by default breaks package builds that use -Werror.

-- Lennart

Change History

Changed 6 years ago by guest

  • status changed from new to closed
  • resolution set to invalid

Changed 6 years ago by igloo

(Can you please not close bugs without comment or anonymously? Thanks)

On the name of the flag, -fwarn rather than -W seems to be the naming convention.

However, on having the warning on by default:

We've seen a number of failures in the HEAD+extralibs build because of this warning, e.g. a warning about index in the below snippet from regex-compat:

else let index = (read (head bgroups)) - 1
     in
     if index == -1
        then match
        else groups !! index

Here, and I imagine everywhere (non-contrived) that compilation succeeds, monomorphism is exactly what we want. As I believe it is a good policy to keep code -Wall clean, I personally would not like this warning to be enabled even by -Wall. Debatably it would be good style to add a type signature for index, though.

The warning may be useful for people investigating removing or replacing the MR, but they can enable it themselves.

It may also be useful to show any such warnings when compilation fails, but that feels like a bit of a hack and may result in a flood of unrelated warnings when a single error occurs.

I've turned the warning off for now, so at least it won't break the nightly builds.

Changed 6 years ago by simonpj

Let me observe that

  • Many newbie complaints are due to silent application of the MR
  • It can always be suppressed by adding a type signature

Perhaps one could make a case to allowing silent MR for nested defns, like the one above.

In any case, I don't feel strongly enough to reopen this. For now it can stay off by default.

Simon

Changed 6 years ago by simonmar

  • status changed from closed to reopened
  • resolution invalid deleted
  • summary changed from -fwarn-monomorphism-restriction should be -Wmonomorphism-restriction to -Wall doesn't include all warnings

-Wall should enable all warnings, otherwise it's badly named. So if we have -fwarn-monomorphism-restriction at all, it should be in -Wall, and possibly also in -W. I personally think it's useful and we should have it, but it should not be enabled by default.

If you use -Wall -Werror, you should expect your code to break whenever a new warning is added. Perhaps we should emit a warning for this option combination :-)

Incedentally, the following warnings are not in -Wall (I believe we should fix this):

  • -fwarn-simple-patterns
  • -fwarn-tabs
  • -fwarn-incomplete-record-updates

Changed 6 years ago by igloo

gcc, from which I assume we get the name -Wall, says in its info page:

The following `-W...' options are not implied by `-Wall'.  Some of
them warn about constructions that users generally do not consider
questionable, but which occasionally you might wish to check for;
others warn about constructions that are necessary or hard to avoid in
some cases, and there is no simple way to modify the code to suppress
the warning.

While it is poorly named, I think that the above list plus -fwarn-monomorphism-restriction fall into the same category.

Changed 6 years ago by simonmar

  • status changed from reopened to closed
  • resolution set to fixed

Ok, I'm convinced. -Wall would be rather less useful if it really included all warnings. I've updated the documentation to match the current behaviour.

I'm ambivalent about whether -fwarn-monomorphism-restriction should be in -Wall; Simon PJ believes it should be. That discussion can be moved to the mailing list, however.

Changed 5 years ago by simonmar

  • architecture changed from Unknown to Unknown/Multiple

Changed 5 years ago by simonmar

  • os changed from Unknown to Unknown/Multiple
Note: See TracTickets for help on using tickets.