tags:

views:

212

answers:

4

Preamble: I know, disabling warnings is not a good idea. Anyway, I have a technical question about this.


Using GCC 3.3.6, I get the following warning:

choosing ... over ... because conversion sequence for the argument is better.

Now, I want to disable this warning as described in gcc warning options by providing an argument like

-Wno-theNameOfTheWarning

But I don't know the name of the warning. How can I find out the name of the option that disables this warning?


I am not able to fix the warning, because it occurs in a header of an external library that can not be changed. It is in boost serialization (rx(s, count)):

template<class Archive, class Container, class InputFunction, class R>
inline void load_collection(Archive & ar, Container &s)
{
    s.clear();
    // retrieve number of elements
    collection_size_type count;
    unsigned int item_version;
    ar >> BOOST_SERIALIZATION_NVP(count);
    if(3 < ar.get_library_version())
        ar >> BOOST_SERIALIZATION_NVP(item_version);
    else
        item_version = 0;
    R rx;
    rx(s, count);
    std::size_t c = count;
    InputFunction ifunc;
    while(c-- > 0){
        ifunc(ar, s, item_version);
    }
}

I have already tried #pragma GCC system_header but this had no effect. Using -isystem instead of -I also does not work.

The general question remains is: I know the text of the warning message. But I do not know the correlation to the gcc warning options.

+6  A: 

How about change your code to remove the warning? It sounds like you probably should cast one of your parameters to a specific type instead of having the compiler choose which cast to do.

Robert
This is not possible, because it occurs in an external library. For more details, I edited my original question.
SebastianK
@Sebastian: Curious that you say both it's not possible and "I fixed the warning in the external library, this really wasn't a big issue." ;)
Roger Pate
@Roger Pate :) Fixing it was not a big issue, but changing it created additional effort due to internal processes, that I tried to avoid.
SebastianK
+3  A: 

Two points: You should leave warnings on - compiler warnings bode ill later on - crashes, corruption, etc.

The used to be the -Wnotanidiot flag. This was around in late version 2.9 ... 3.o of gcc. I don't know if it still works, but this warning would qualify.

jim mcnamara
http://gcc.gnu.org/ml/gcc-bugs/2000-06/msg00187.html
jim mcnamara
In case someone thinks I'm being a jerk. Some warnings for some programmers have little merit. Phil Edwards created an add-on. It was available. Whether it is apropos for this discussion you can decide, but it did exist. I played with it myself.
jim mcnamara
Interesting how some people think the *factual reporting* of a real feature in gcc is offensive. Three people have flagged it as such. How do such sensitive flowers survive in this modern world of ours?
APC
+7  A: 

You can find out what option is associated with a given warning by using the -fdiagnostics-show-option option:

$ gcc -fdiagnostics-show-option -Wall foo.c
foo.c: In function ‘main’:
foo.c:3: warning: suggest parentheses around assignment used as truth value [-Wparentheses]

And my two cents about this: assuming there's no way to actually fix the warning, hopefully you can manage to disable the warning for a minimal amount of compilation, so that if you make a similar mistake in your own code, you'll be warned.

Edit: This appears to be -Wconversion. (Found by poking in the source - you can just grep for some of the warning text, and find the call to warning( OPT_W_conversion, ....)

Jefromi
Unfortunately, in GCC 3.3.6 this option is not available.
SebastianK
@SebastianK: Well, that's awkward. Hopefully `-isystem` will work out for you, but if it doesn't... I'd try and take your code somewhere else and compile with a newer version of GCC. It looks like you can probably make a pretty minimal test case that'll produce the warning?
Jefromi
@SebastianK: I think I found it for you... but I'd still try and do what you can to avoid actually turning off warnings, of course!
Jefromi
@Jefromi Thanks for your help, but neither `-isystem` nor `-Wno-conversion` disable the warning.
SebastianK
@SebastianK: That's... odd. That was the only place I found that given warning text in the source. I think I've done about all I can do without you actually providing code which provokes the warning.
Jefromi
I fixed the warning in the external library, this really wasn't a big issue. I had clearly preferred to leave it untouched, but now, changing it seems to be the best option. Thanks, Jefromi.
SebastianK
@Jefromi: when you checked the source, did you check the gcc3 source or the gcc4 source?
Bill
@Bill: I did look at gcc4 source, but then I looked at the gcc3 documentation and saw that the warning was available then too, with basically the same description.
Jefromi
@Jefromi: Excellent! I don't have access to gcc3 here, and don't know if those ever change from version to version.
Bill
A: 

The answer to the question, "How can I find out the name of the option that disables this warning?" is "Read the source of the compiler."

bmargulies