TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

A very old gcc "bug"

14 点作者 vinutheraj超过 15 年前

3 条评论

Dilpil超过 15 年前
My favorite gcc trick is to compile and run the following two line, and then try to reconcile the results.<p>x = 7;<p>printf("%d %d %d",x++,++x,x++);<p>x = 7;<p>printf("%d %d %d",x++,x=2,x++);<p>Go ahead, try it, run it, and explain the output.
评论 #902380 未加载
评论 #902381 未加载
评论 #902411 未加载
zandorg超过 15 年前
I find it hard to believe that you wouldn't know how many registers code should use. However - it's not C code, it's assembly code, so it seems unfair to blame gcc - a <i>C</i> compiler.
评论 #902219 未加载
评论 #902209 未加载
jacquesm超过 15 年前
read comment #24:<p>Martin, you should realize that this problem <i>cannot</i> be solved. Yes, there will perhaps be a time when this particular test case compiles, though I think that is unlikely. But anyway, then there will be other cases that fail.<p>The reason is dead simple: register allocation is NP-complete, so it is even <i>theoretically</i> not possible to write register allocators that always find a coloring. That means any register allocator will always fail on some very constrained asm input. And you cannot allow it to run indefinitely until a coloring is found, because then you've turned the graph coloring problem into the halting problem because you can't prove that a coloring exists and that the register allocator algorithm will terminate.<p>So really it doesn't matter at all whether or not your specific inline asm compiles or not. When yours does, someone else's will fail.
评论 #902271 未加载
评论 #902230 未加载