These conversions cause many bugs and refactoring pain with incorrect overloads getting called, etc. I can't think of one good reason why these conversions should be implicit, except for compatibility.
PLEASE consider deprecating these conversions in an upcoming revision of the C++ standard.
(And if compatibility with C is quoted as a reason for not doing so - then C should also deprecate these conversions. C should also adopt C++'s nullptr.)
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposal...@isocpp.org.
To post to this group, send email to std-pr...@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
On Wednesday, September 24, 2014 6:35:00 PM UTC-7, daryl.va...@maptek.com.au wrote:
(And if compatibility with C is quoted as a reason for not doing so - then C should also deprecate these conversions. C should also adopt C++'s nullptr.)
Two problems with that: first, the reason is probably compatibility with the
hundreds of millions of lines of code that expect that to work. It's extremely
common to write:
if (p)
Anyway, as a QoI, your compiler should be able to warn of those uses,
especially the use of literal zero for a null pointer.
#include <sys/socket.h> // SHUT_WR is an enum whose value is 1
int main()
{
char *purr = false;
static_cast<void>(purr);
char *meow = ((4059079107ULL * 653022955U) & 4294967295U) - SHUT_WR;
static_cast<void>(meow);
return 0;
}
#include <cstdint>
template <char...>
constexpr std::uint32_t operator "" _u32()
{
return UINT32_C(0);
}
int main()
{
char *meow = 0_u32;
static_cast<void>(meow);
return 0;
}
As others have said, this is not likely to happen - for many good reasons.
In hindsight, you might have saved yourself a lot of trouble by
deleting the function instead of removing it: void foo(int IntValue) =
delete;