嗷嗷的话:

这都是一些细枝末节的东西,我想不做编译器的话,大部分都很难碰到。研究学习这些只是出于对C语言一种偏执狂。

写出来是为了找到和我一样的偏执狂。

在随后的的文章中,首先我写一写191种undefined behavior。不一定是对的,只是我自己的理解。参考的标准是C99.

undefined behavior简单来说就是,如果你的程序违反了C标准中某些准则,那么具体会发生什么,C标准没有定义,也就说得到任何奇怪的结果,都是有可能的。比如说整数溢出就是一个undefined behavior。
unspecified behavior简单来说就是,C标准提供了多种可选方案,具体选择哪一个并没有定义。比如说,函数计算他参数的顺序是一个unspecified behavior。以任何顺序计算都可以。i = i++ + i++;的值也是一个unspecified behavior。

本系列其他文章传送门:

C语言中的undefined behavior系列(1)-- linkage of identifier

一下摘于C99标准。关于behavior的定义

behavior -- external appearance or action

implementation-defined behavior -- unspecified behavior where each implementation documents how the choice is made  
  EXAMPLE An example of implementation-defined behavior is the propagation of the high-order bitwhen a signed integer is shifted right.


locale-specific behavior -- behavior that depends on local conventions of nationality, culture, and language that each implementation documents

EXAMPLE An example of locale-specific behavior is whether the islower function returns true for characters other than the 26 lowercase Latin letters

undefined behavior -- behavior, upon use of a nonportable or erroneous program construct or of erroneous data,for which this International Standard imposes no requirements

NOTE Possible undefined behavior ranges from ignoring the situation completely with unpredictableresults, to behaving during translation or program execution in a documented manner characteristic of the environment (with or without the issuance of a diagnostic message), to terminating a translation or execution (with the issuance of a diagnostic message).

EXAMPLE An example of undefined behavior is the behavior on integer overflow

unspecified behavior  behavior where this International Standard provides two or more possibilities and imposes no further requirements on which is chosen in any instance

EXAMPLE An example of unspecified behavior is the order in which the arguments to a function are evaluated.

【转载】C语言中的undefined behavior/unspecified behavior - 序的更多相关文章

  1. C语言中的undefined behavior

    参考: http://www.cnblogs.com/aoaoblogs/archive/2010/08/31/1813982.html

  2. 转载 C语言中volatile关键字的作用

    一.前言 1.编译器优化介绍: 由于内存访问速度远不及CPU处理速度,为提高机器整体性能,在硬件上引入硬件高速缓存Cache,加速对内存的访问.另外在现代CPU中指令的执行并不一定严格按照顺序执行,没 ...

  3. C语言中do...while(0)的妙用(转载)

    转载来自:C语言中do...while(0)的妙用,感谢分享. 在linux内核代码中,经常看到do...while(0)的宏,do...while(0)有很多作用,下面举出几个: 1.避免goto语 ...

  4. 【转载】C语言中的static 详细分析

    原blog地址:http://blog.csdn.net/keyeagle/article/details/6708077/ google了近三页的关于C语言中static的内容,发现可用的信息很少, ...

  5. C语言中.h和.c文件解析(转载)

    转载:http://www.cnblogs.com/laojie4321/archive/2012/03/30/2425015.html   简单的说其实要理解C文件与头文件(即.h)有什么不同之处, ...

  6. C语言中file文件指针概念及其操作 (转载)

    文件 文件的基本概念 所谓"文件"是指一组相关数据的有序集合. 这个数据集有一个名称,叫做文件名.实际上在前面的各章中我们已经多次使用了文件,例如源程序文件.目标文件.可执行文件. ...

  7. C语言中,头文件和源文件的关系(转)

    简单的说其实要理解C文件与头文件(即.h)有什么不同之处,首先需要弄明白编译器的工作过程,一般说来编译器会做以下几个过程: 1.预处理阶段 2.词法与语法分析阶段 3.编译阶段,首先编译成纯汇编语句, ...

  8. c语言中time相关函数

    工作中遇到的函数: int seed = time(NULL); srand(seed); signal(SIGINT, stop); signal(SIGUSR1, sig_usr1); 搜time ...

  9. C语言中的static 详细分析

    转自:http://blog.csdn.net/keyeagle/article/details/6708077/ google了近三页的关于C语言中static的内容,发现可用的信息很少,要么长篇大 ...

随机推荐

  1. c# 重写索引

    //using System;//using System.Collections.Generic;//using System.Text; //namespace 索引//{//    class ...

  2. LNMP安装成功的界面

    在ubuntu13.10上面安装一个lnmp集成环境. 下面是安装成功的界面. ===========================add nginx and php-fpm on startup ...

  3. 再谈对协变和逆变的理解(Updated)

    去年写过一篇博客谈了下我自己对协变和逆变的理解,现在回头看发现当时还是太过“肤浅”,根本没理解.不久前还写过一篇“黑”Java泛型的博客,猛一回头又是“肤浅”,今天学习Java泛型的时候又看到了协变和 ...

  4. 整理的dedecms标签大全,方便查找

    平时用dedecms开发经常会用到一些标签,特别是首页.栏目页.内容页,这些页面都会用到标签的调用,比如title.keywords.description.arclist.field.body等,为 ...

  5. mysql 启动错误

    错误提示如下: 150815 20:24:40 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended150815 20:2 ...

  6. Linux MySQL差异备份技巧

    MSSQL差异备份使用技巧 15 Apr 2013 所谓的差异备份,就是只备份最近一次备份之后到此次备份之前所增加的那一部分数据.打个比方我第N次备份后数据库存放的内容是ABCD,然后我第N+1次 备 ...

  7. 【Django】Django 如何使用 Django设置的日志?

    代码: from django.core.management.base import BaseCommand, CommandError from django.db import models # ...

  8. 57. 数对之差的最大值:4种方法详解与总结[maximum difference of array]

    [本文链接] http://www.cnblogs.com/hellogiser/p/maximum-difference-of-array.html [题目] 在数组中,数字减去它右边的数字得到一个 ...

  9. (转)JAVA AJAX教程第一章-初始AJAX

    既然是认识AJAX,理论和实践相结合,这样让自己学的更快,理解更深入,我分一下几点: 1.  认识传统的同步交互方式和AJAX解决方案 2.  AJAX使用到的技术 3.  实例体验AJAX 一.同步 ...

  10. JS Replace 全部替换字符 用法

    转载自:http://www.cnblogs.com/skykang/archive/2011/08/04/2127158.html <script language="javascr ...