gpt4 book ai didi

c++ - 由于 LARGEADDRESSAWARE 检测指针算术

转载 作者:可可西里 更新时间:2023-11-01 17:57:18 26 4
gpt4 key购买 nike

我想将我的应用程序切换到 LARGEADDRESSAWARE。需要注意的问题之一是指针运算,因为指针差异不能再表示为带符号的 32b。

有什么方法可以在大型 C++ 项目中自动查找指针减法的所有实例吗?

如果没有,是否有一些“最省力”的手动或半自动方法如何实现?

最佳答案

PC-Lint 可以发现这类问题。

http://gimpel-online.com/MsgRef.html , 错误代码 947:

Subtract operator applied to pointers -- An expression of the form p - q was found where both p and q are pointers. This is of special importance in cases where the maximum pointer can overflow the type that holds pointer differences. For example, suppose that the maximum pointer is 3 Gigabytes -1, and that pointer differences are represented by a long, where the maximum long is 2 Gigabytes -1. Note that both of these quantities fit within a 32 bit word. Then subtracting a small pointer from a very large pointer will produce an apparent negative value in the long representing the pointer difference. Conversely, subtracting a very large pointer from a small pointer can produce a positive quantity.

关于c++ - 由于 LARGEADDRESSAWARE 检测指针算术,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3052028/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com