This is the mail archive of the gcc-bugs@gcc.gnu.org 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]

Re: Inappropriate Warning Cannot Be Turned Off


> The code is correct, but the ISO rules are confusing; this comes from
> call.c
> 
>   /* warn about confusing overload resolution for user-defined conversions,
>      either between a constructor and a conversion op, or between two
>      conversion ops.  */
> 
> You'd have to ask Jason for the exact rationale why there is no option
> to turn it off. We had *many* bug reports where people claimed that
> the compiler did the wrong thing, when in fact there understanding of
> C++ was wrong. Without the warning, they even would not have known
> that that the compiler did not what they expected. So overall, I'd say
> this feature has proven useful. In many cases, it is possible to
> adjust the code by adding a third conversion operator.

In my case, I was *not* able to adjust the code. I tried very hard to. In
fact, I started a long thread on comp.lang.c++.moderated about this very
thing, before I starting claiming this as a compiler bug.

I posted a short example, showed the warnings, and asked how I might suppress
the warning. There were many suggestions by several people, and I tried all of
them. None of them would suppress the warning.

I then asked if it was reasonable, what I was trying to do. (Basically,
defining an "Auto-zeroing" number type which behaves in every other way as
close to int as possible.) The consensus was that, yes, it was reasonable to
do this.

I would gladly adjust the code to suppress the warning. But I haven't been
able to. So, then, finding no option to disable this warning, I redefined gcc
to be "gcc |gcc_warnings_filter", where gcc_warnings_filter is an awk program
to filter out this and a couple other warnings. Needless to say, I am rather
uncomfortable with this solution :)

Perhaps you are right, that this is C++-mandated behavior. I cannot comment
from authority on this. But I am entirely comfortable with this behavior, and
the compiler is doing exactly what I want it to do. But, if that is true, what
I don't want is a warning about correct usage. 

At the very least, if you are convinced that a warning should be supplied by
default, there should at least be a way to turn this specifically off.

This is the first time, ever, that I have got a warning in my own C++ code
compiled by gcc that I haven't been able to suppress by a combination of
rewriting my code and, failing that, by -Wno- options.


-- DavidC

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