Here is the code I used for testing:
\nclass OtherClass\n{\npublic:\n\n bool Address(const char *address);\n\n inline const char *Address(bool bUseDot = true) const ;\n};\n\n\nvoid tryThis()\n{\n OtherClass m_addr;\n const char *m_server_address = m_addr.Address(false);\n}\n
Works just as badly as the original.
Here is the debug output:
\ng++ -c test.cpp\ntest.cpp: In function `void tryThis()':\ntest.cpp:25: warning: from "OtherClass*" "&m_addr"to "const OtherClass*" using\ntest.cpp:25: warning: qual_conv\ntest.cpp:25: warning: identity_conv\ntest.cpp:25: warning: &m_addr\n\ntest.cpp:25: warning: from "bool" "false"to "bool" using\ntest.cpp:25: warning: identity_conv\ntest.cpp:25: warning: false\n\ntest.cpp:25: warning: from "OtherClass*" "&m_addr"to "OtherClass*" using\ntest.cpp:25: warning: identity_conv\ntest.cpp:25: warning: &m_addr\n\ntest.cpp:25: warning: from "bool" "false"to "const char*" using\ntest.cpp:25: warning: std_conv\ntest.cpp:25: warning: identity_conv\ntest.cpp:25: warning: false\n\ntest.cpp:25: choosing `const char* OtherClass::Address(bool) const' over `bool\n OtherClass::Address(const char*)'\ntest.cpp:25: because worst conversion for the former is better than worst\n conversion for the latter\n\nCompilation exited abnormally with code 1 at Tue Jan 21 21:31:05\n
So, it takes 2 conversions to go from false to (const char *)
Here are relevant paragraphs from [link|http://www.comnets.rwth-aachen.de/doc/c++std/conv.html|C++ standard:]
>>>>>>>>>>>>>>>>>>>>>>>
1 Standard conversions are implicit conversions defined for built-in
types. The full set of such conversions is enumerated in this clause.
A standard conversion sequence is a sequence of standard conversions
in the following order:
--Zero or one conversion from the following set: lvalue-to-rvalue con-
version, array-to-pointer conversion, and function-to-pointer con-
version.
--Zero or one conversion from the following set: integral promotions,
floating point promotion, integral conversions, floating point con-
versions, floating-integral conversions, pointer conversions,
pointer to member conversions, and boolean conversions.
--Zero or one qualification conversion.
[Note: a standard conversion sequence can be empty, i.e., it can con-
sist of no conversions. ] A standard conversion sequence will be
applied to an expression if necessary to convert it to a required des-
tination type.
........
4 An rvalue of type bool can be converted to an rvalue of type int, with
false becoming zero and true becoming one.
.........
1 An integral constant expression (_expr.const_) rvalue of integer type
that evaluates to zero (called a null pointer constant) can be con-
verted to a pointer type. The result is a value (called the null
pointer value of that type) distinguishable from every pointer to an
object or function. Two null pointer values of the same type shall
compare equal. The conversion of a null pointer constant to a pointer
to cv-qualified type is a single conversion, and not the sequence of a
pointer conversion followed by a qualification conversion
(_conv.qual_).
<<<<<<<<<<<<<<<<<<<
So, GCC is right. And I have to concede: C++ is a sick language.
However, the correct conversion should still be picked by comparing length of path for 2 possibilities. The text that Scott saw on screen was a "pedantic warning" - something less than a regular warning. It should never fail the compilation. I'll try to find out why the exit code is 1 after that "pedwarn".