为什么 C++ 中的有符号整数溢出是未定义的而不是实现定义的?

问题描述 投票:0回答:0

根据我在网上的发现,有符号整数溢出在 C++ 中是未定义的,因为我们根本没有只有一种表示有符号整数的方法。但我不明白为什么这不能使其成为实现定义的,其中每个实现本身都可以根据其对有符号整数的表示为有符号溢出提供定义明确的行为。

c++ language-lawyer undefined-behavior implementation-defined-behavior signed-overflow
© www.soinside.com 2019 - 2024. All rights reserved.