段错误的IA-64,而不是在IA-32 [英] Segfault on IA-64, but not on IA-32

查看:204
本文介绍了段错误的IA-64,而不是在IA-32的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法访问我的原来的帐户。主持人被要求合并账户如果可能的话。结果
这里是我的问题。
IA-64的下面的C程序设计缺陷,但能正常工作在IA-32。

I can't access my original account. Moderators are requested to merge the accounts if possible.
Here is my question. The following C program segfaults of IA-64, but works fine on IA-32.

int main()
  {
      int* p;
      p = (int*)malloc(sizeof(int));
      *p = 10;
      return 0;
  }

为什么会这样发生的?

Why does it happen so?

推荐答案

在C,其默认的返回类型为 INT 如果函数原型没有。在IA64指针的大小是大于int,所以它能够段错误。

In C the default return type is int if the function is not prototyped. In ia64 the size of a pointer is larger than an int and so it can segfault.

更新:这个问题基本上是为什么你应该总是你的原型函数(或包括为此事适当的头)

Update: The question is basically why you should always prototype your functions (or include the appropriate headers for that matter).

这篇关于段错误的IA-64,而不是在IA-32的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆