N
Norman Diamond
For the second time I have found Visual Studio 2005 silently accepting C++
source code that violates constraints, for which the standard requires
diagnostics.
The first case involved source code in a Microsoft publication targeting
writers of device drivers, I wondered how it could even compile, but it did
compile without a peep. Microsoft already resolved that as a "won't fix"
for the next version of Visual Studio after 2005.
Today's case involves source code not from Microsoft and not as critical as
a device driver. I'm not going to bother submitting this one for a "won't
fix". Here's a repro:
class ok_class {
public:
void ok_member(void* const & ok_param) {}
void ok_member(void*& ok_param) {}
} ok, *p_ok = &ok;
typedef void* const & ok_reference;
typedef void*& bad_reference;
int APIENTRY _tWinMain(
// .....
ok.ok_member((ok_reference) p_ok);
ok.ok_member((bad_reference) p_ok); // illegal but silently accepted
source code that violates constraints, for which the standard requires
diagnostics.
The first case involved source code in a Microsoft publication targeting
writers of device drivers, I wondered how it could even compile, but it did
compile without a peep. Microsoft already resolved that as a "won't fix"
for the next version of Visual Studio after 2005.
Today's case involves source code not from Microsoft and not as critical as
a device driver. I'm not going to bother submitting this one for a "won't
fix". Here's a repro:
class ok_class {
public:
void ok_member(void* const & ok_param) {}
void ok_member(void*& ok_param) {}
} ok, *p_ok = &ok;
typedef void* const & ok_reference;
typedef void*& bad_reference;
int APIENTRY _tWinMain(
// .....
ok.ok_member((ok_reference) p_ok);
ok.ok_member((bad_reference) p_ok); // illegal but silently accepted