Date: Wed, 10 Sep 2025 10:59:26 -0400
On Sep 10, 2025, at 6:10 AM, Lénárd Szolnoki via Std-Proposals <std-proposals_at_[hidden]> wrote:
>
> If a C library has something like:
>
> void foo(_BitInt(16) x);
>
> , then it can plausibly have documentation and example code with foo(42) or foo(some_int) in it. It can be confusing and add friction when the same C library has subtly different interfaces from C and from C++.
Good example!
But I see it from the other side of the the fence. I think it would be a good thing if foo(some_int) did not compile when switching from C to C++. I.e. switch from C to C++ and you can catch some run-time UB at compile-time. That looks like a good safety feature to me.
foo(42) is another matter. I’d love for the compiler to be smart enough to recognize that the compile-time value is safe to narrow.
Howard
>
> If a C library has something like:
>
> void foo(_BitInt(16) x);
>
> , then it can plausibly have documentation and example code with foo(42) or foo(some_int) in it. It can be confusing and add friction when the same C library has subtly different interfaces from C and from C++.
Good example!
But I see it from the other side of the the fence. I think it would be a good thing if foo(some_int) did not compile when switching from C to C++. I.e. switch from C to C++ and you can catch some run-time UB at compile-time. That looks like a good safety feature to me.
foo(42) is another matter. I’d love for the compiler to be smart enough to recognize that the compile-time value is safe to narrow.
Howard
Received on 2025-09-10 14:59:59