C++ Logo

std-proposals

Advanced search

Re: [std-proposals] mandatory compiler diagnostic for converting function to boolean

From: Matthew Taylor <mjtaylor214_at_[hidden]>
Date: Fri, 8 Sep 2023 22:07:02 +0000
As far as I can see, this falls into the old category of implicit conversions between the integral types inherited from C. Yes it creates problems and confusing situations, and yes if we could start again from scratch we probably wouldn't include it, but we have to live with it for legacy/cross-compatibility reasons and that's just that.

I don't think limiting to this one specific case is really a solution so much as it is a bandaid - should all such implicit conversions be ill-formed or just the ones you think no reasonable person would use? How confident are you that there are no legitimate use-cases for what you're proposing? What happens when code which has been fine for 30 years breaks because of it? Indeed, I'm pretty sure any proposal to break with C/legacy in this way will be DOA; especially as the big three compilers already warn in the situation you describe (though admittedly gcc needs extra warnings enabled): https://godbolt.org/z/86b6bE9rz





Received on 2023-09-08 22:07:04