Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C 什么是“的解释?”;警告:假设循环不是无限的;_C_Gcc_Gcc Warning - Fatal编程技术网

C 什么是“的解释?”;警告:假设循环不是无限的;

C 什么是“的解释?”;警告:假设循环不是无限的;,c,gcc,gcc-warning,C,Gcc,Gcc Warning,我刚刚决定将尽可能多的变量从unsigned更改为int,重新编译相关代码时,收到以下警告消息: freespace_state.c:203: warning: assuming that the loop is not infinite 所涉行: for (x = startx; x <= endx; ++x, ++xptr) for(x=startx;x我认为GCC告诉您,它无法确定循环不是无限的,并且正在进行编译。这是一个警告,而不是一个错误,这是您可能需要考虑的事情。根据,GC

我刚刚决定将尽可能多的变量从
unsigned
更改为
int
,重新编译相关代码时,收到以下警告消息:

freespace_state.c:203: warning: assuming that the loop is not infinite
所涉行:

for (x = startx; x <= endx; ++x, ++xptr)

for(x=startx;x我认为GCC告诉您,它无法确定循环不是无限的,并且正在进行编译。这是一个警告,而不是一个错误,这是您可能需要考虑的事情。

根据,GCC似乎正在执行“不安全的循环优化”(由于设置了
-funsafe循环优化
,您将收到警告)。如果循环无限大,此特定优化将以某种方式失败

既然你说这是一个终止循环,听起来好像你没什么好担心的

修补程序的另一个相关部分:

@opindex Wunsafe-loop-optimizations Warn if the loop cannot be optimized because the compiler could not assume anything on the bounds of the loop indices. With @option{-funsafe-loop-optimizations} warn if the compiler made +such assumptions. @opindex Wunsafe循环优化 如果由于编译器无法优化而无法优化循环,则发出警告 假设循环索引的边界上的任何内容 @选项{funsafe loop optimizations}如果编译器 +这些假设。
GCC警告您的原因是因为它已经退出了一个不安全的优化

for (x = startx; x <= endx; ++x, ++xptr)

for(x=startx;x多么奇怪的消息……我一直在试图理解它是否与上的博客文章有关,但发出用户可见的警告是很奇怪的。该博客文章涉及沉默(并且有效性有争议)优化。你确定你没有在这个循环中混合使用
int
unsigned
吗?所有这些变量现在都是
int
s吗?@AndreyT:除了xptr之外,它们都是int,xptr是指向uint64\u t的指针。这对我来说似乎很有意义。运行时错误永远不会由编译时错误产生,但可能是未被注意的警告的结果gs。
for( x = startx; x < (endx+1); ++x, ++xptr)