This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Warnings in templates

Jason Merrill wrote:

On Mon, 31 May 2004 11:17:52 -0700, Mark Mitchell <> wrote:

Do you understand why we seem to be trying so hard to issue warnings
about things like functions that do not return in templates?

The idea was to try to catch obvious errors as soon as possible. Certainly
we need to be conservative about it to avoid getting too many false
positives. I expected that the number of false positives would be small
compared to the number of true positives, so the warning would be
worthwhile overall. But I'm open to other views.

Generally, I'm of the opinion that if the number of false positives is non-zero, we've got a bug.

We're certainly going to get bug reports about such cases. (Including from people who use -Werror.) It's not easy for many users to understand the reason that the compiler will issue warnings in some cases but not others. "We don't warn about that in a template until it's instantiated" is easier to understand than "We warn about that in templates, but may generate false positives if some of the function call arguments are dependent." I believe that's also more consistent with the practice of other compilers.

There are cases (like an "expression has no effect" warning in a template on the statement "3;") that we could issue with zero false positives in a template, and issuing those make sense to me. If we're not sure, we can defer the warning until instantiation time. I think things where we can't avoid false positives should be deferred until instantiation time.

Mark Mitchell
CodeSourcery, LLC
(916) 791-8304

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]