This would explain some behaviour I saw in the services agent before I
reworked it.
Good work.
On Fri, Jul 8, 2011 at 12:24 AM, Zane Bitter <zbitter(a)redhat.com> wrote:
Cross-posting this to the matahari list, as it could quite possibly
affect anyone else trying to write a matahari agent.
-------- Original Message --------
Subject: [jira] [Created] (QPID-3344) Comparisons of const DataAddr
objects are incorrect
Date: Thu, 7 Jul 2011 13:40:16 +0000 (UTC)
From: Zane Bitter (JIRA) <jira(a)apache.org>
To: zbitter(a)redhat.com
Comparisons of const DataAddr objects are incorrect
---------------------------------------------------
Key: QPID-3344
URL:
https://issues.apache.org/jira/browse/QPID-3344
Project: Qpid
Issue Type: Bug
Components: Qpid Managment Framework
Affects Versions: 0.10
Environment: Fedora 15, not that it matters.
Reporter: Zane Bitter
Assignee: Ted Ross
The following program results in incorrect output:
{code:title=test.cpp}
// g++ test.cpp -o test -lqmf2
#include <qmf/DataAddr.h>
#include <iostream>
int main(void)
{
qmf::DataAddr foo("foo", "blarg", 1);
const qmf::DataAddr bar("bar", "wibble", 2);
// prints "false"
std::cout << "foo == bar: " << (foo == bar ? "true" :
"false") << "\n";
// prints "true" (Doh!)
std::cout << "bar == foo: " << (bar == foo ? "true" :
"false") << "\n";
return 0;
}
{code}
Anywhere where two DataAddr objects are compared and the first is a
const reference will give a bogus result. (Specifically, both operands
are converted to bool before being compared.) The reason is that
DataAddr::operator==() is not declared const, so it will not be used to
compare const references, and that C++ is pure, unadulterated evil.
Not that qmf::Data::getAddr() returns a const qmf::DataAddr&, so this is
likely to be a common problem. Some other APIs, such as
qmf::AgentEvent::getDataAddr() return non-const references, which would
be unaffected (unless they become const at some point in the call chain).
A patch will follow presently.
--
This message is automatically generated by JIRA.
For more information on JIRA, see:
http://www.atlassian.com/software/jira
_______________________________________________
Matahari mailing list
Matahari(a)lists.fedorahosted.org
https://fedorahosted.org/mailman/listinfo/matahari