[cfe-dev] numbered warnings & errors?

Douglas Gregor dgregor at apple.com
Tue Jan 5 07:47:52 PST 2010


On Dec 24, 2009, at 12:09 AM, Daniel Dunbar wrote:

> 2009/12/23 Chandler Carruth <chandlerc at google.com>:
>> On Wed, Dec 23, 2009 at 9:43 PM, Zhanyong Wan (λx.x x) <wan at google.com> wrote:
>>> Hi,
>>> 
>>> Sorry if this has been discussed before.  What do people say to
>>> assigning each warning/error a number and printing that number as part
>>> of the compiler message, like what MSVC does?
>>> 
>>> When we see a compiler error/warning, often we need to read up on what
>>> it really means.  A unique number is much easier to search for than
>>> the actual message, which can change from one version of Clang to
>>> another.  Also different warnings/errors may have similar messages,
>>> making a search even harder.
>>> 
>>> Unique error/warning numbers also make it easier to suppress warnings
>>> using -W or #pragma.  When I see a warning message, I can suppress it
>>> using the warning number in it.  I don't have to look up the symbolic
>>> ID of the warning from the Clang documentation.  (While this problem
>>> can be solved by printing the symbolic ID as part of the message, it's
>>> visually more intrusive.)
>> 
>> Personally, I'd accept the intrusion to have something easier than a
>> number to refer to. It should be equally searchable. But I do agree
>> with printing some identifier, whatever form it takes.
> 
> I also found the MSVC warning numbers to be really useful in practice,
> but want something better. A proposal I thought about making, but
> haven't actually written, was to organize diagnostics into a compact
> reverse dotted notation. The idea being that a fully dotted warning
> should be easy to google / search docs for, and the components in the
> dot could be useful for organization and high level grouping.

I like that idea.

> I'm not in a particular rush to see this problem solved though,
> because a lot of the value of having stable warning numbers/names is
> in the stability, so letting our diagnostics bake for a while is good.

Agreed. What I *don't* want is for us to feel restricted by an existing numbering system, where we don't want to improve diagnostics (e.g., by splitting one diagnostic into several) because some users may have suppressed that diagnostic with a pragma.

> I'm also curious about alternate approaches which don't rely on
> exposing a stable name to the user (for example, by having the
> compiler embed some of the documentation, which could then have a
> verbose link to more information -- it would still be keyed by some
> number + version, but not in a way that needs to be stable).


I take it as gospel that the documentation should be embedded in the compiler, and then any external representation of that documentation can be generated by the compiler itself. A reverse dotted notation will help us organize that documentation, and force us into the right mental model for keeping diagnostics within a particular are of the compiler consistent.

  - Doug





More information about the cfe-dev mailing list