IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New This is what bugs me in Scott's problem...
>>>>>>>>>>>>>
If you define a member function and make it const, you can call it with both a const and non-const ref to the object.
<<<<<<<<<<<<

He has a const member function. There is really no conversion involved in calling const function on non-const reference. What the hell does compiler want from the poor guy?

One more thing. In this code:

\nclass OtherClass\n{\npublic:\n\n\tbool Address(const char *address);\n\n\tinline std::string Address(bool bUseDot = true) const ;\n};\n\n\nvoid tryThis()\n{\n    OtherClass m_addr;\n\tstd::string m_server_address = m_addr.Address(false/*replace here*/);\n}\n\n

If I replace "false" in tryThis() with "true", it compiles fine. Could GCC be trying to interpret "false" as NULL? Dumb, I know.

--

We have only 2 things to worry about: That
things will never get back to normal, and that they already have.
New I was pissed enough at the problem
I hacked gcc code to report on what conversions take place.

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".


--

We have only 2 things to worry about: That
things will never get back to normal, and that they already have.
New I was pissed enough that I:
Switched to 2.95.4 with stlport, which works "wonderfully" (read: sufficiently crummy version of wonderful as defined by the C++ spec) as compared to 3.2.1.
Regards,

-scott anderson

"Welcome to Rivendell, Mr. Anderson..."
New Solution
`-fpermissive'
Downgrade messages about nonconformant code from errors to
warnings. By default, G++ effectively sets `-pedantic-errors'
without `-pedantic'; this option reverses that. This behavior and
this option are superseded by `-pedantic', which works as it does
for GNU C.


I think GCC is no less fucked than C++ standard. But at least you can make it swallow the code.
--

We have only 2 things to worry about: That
things will never get back to normal, and that they already have.
New ROFL
But at least you can make it swallow the code.


gcc: the compiler that swallows, not spits.
Regards,

-scott anderson

"Welcome to Rivendell, Mr. Anderson..."
New Re: "..you can make it swallow the code." Beautiful!
Alex

"No man's life, liberty, or property are safe while the legislature is in session."\t-- Mark Twain
     I *heart* C++ - (admin) - (30)
         GNU compilers both sides? - (marlowe)
         What is the type of m_server_address? - (Arkadiy) - (3)
             As noted: - (admin) - (2)
                 Re: As noted: - (deSitter) - (1)
                     It isn't. - (admin)
         Fix: - (admin) - (24)
             const is a design error - (tuberculosis) - (23)
                 One of my directives for this port: - (admin) - (8)
                     Re: One of my directives for this port: - (deSitter) - (7)
                         The "const" attribute means that, within the given scope,... - (a6l6e6x) - (6)
                             Because it's not supposed to be modified... - (ChrisR) - (5)
                                 Yes, I remember all that.. - (deSitter) - (3)
                                     Re: why bother? - (a6l6e6x) - (2)
                                         Well, yes, that was what BS was obsessing on - (deSitter) - (1)
                                             Clearly BS hates programmers and doesn't trust them - (tuberculosis)
                                 Re: Because it's not supposed to be modified... - (JimWeirich)
                 Re: const is a design error - (JimWeirich) - (13)
                     Only if such differences exist - (tuberculosis) - (12)
                         Fun in computing. - (static)
                         Re: Only if such differences exist - (JimWeirich) - (10)
                             const functions - (tuberculosis) - (9)
                                 Well, it doesnt' appear to be overloaded on const - (Simon_Jester) - (8)
                                     Re: Well, it doesnt' appear to be overloaded on const - (JimWeirich)
                                     No, thats exactly the problem - (tuberculosis) - (6)
                                         This is what bugs me in Scott's problem... - (Arkadiy) - (5)
                                             I was pissed enough at the problem - (Arkadiy) - (4)
                                                 I was pissed enough that I: - (admin) - (3)
                                                     Solution - (Arkadiy) - (2)
                                                         ROFL - (admin)
                                                         Re: "..you can make it swallow the code." Beautiful! -NT - (a6l6e6x)

Why not just name him Hitler B. Evil?
55 ms