【问题标题】:What are potential issues with the following code? short foo() { short a,b,c; b=10; c = a + b; return c; } [closed]以下代码有哪些潜在问题?短 foo() { 短 a,b,c; b=10; c = a + b;返回 c; } [关闭]
【发布时间】:2015-04-28 01:34:43
【问题描述】:

以下代码有哪些潜在问题?

short foo()
{
    short a,b,c;
    b=10;

   c = a + b;

   return c; 
 }

【问题讨论】:

  • a 未定义!从这里开始
  • 使用未初始化的a 会导致未定义的行为。
  • 如果函数签名改为short foo(short a) 并且a作为堆栈变量被移除怎么办?

标签: c type-conversion initialization arguments


【解决方案1】:

变量 a 未初始化。它有一个不确定的值。

【讨论】:

  • 有一点要关闭:Questions seeking debugging help你可以随意使用
猜你喜欢
  • 1970-01-01
  • 2012-07-31
  • 2011-08-01
  • 1970-01-01
  • 2015-06-12
  • 2020-12-25
  • 1970-01-01
  • 1970-01-01
  • 2011-05-30
相关资源
最近更新 更多