C语言基本概念之序列点

为什么写这篇文章?

我相信很多人跟我一样,在使用了C语言很长一段时间之后,都不曾知道C中有个序列点(sequence point)的概念。最近翻阅C标准时发现它是个非常重要的概念,理解了它对于消除对C的诸多疑惑大有裨益,也更能提高代码质量。


什么是副作用?

副作用?什么副作用?我相信很多人一脸懵逼,还以为是吃了什么药产生了什么副作用。那么我现在确确切切地告诉你,副作用(side effect)是C中的一个重要概念!

慢着!不是说介绍序列点吗? 怎么先提副作用呢? -- 嘿!要理解序列点的概念啊,还必须先理解什么是副作用,至于原因,下文会详细说到!

好,那么在C中到底什么是副作用呢?老规矩,先看看标准中怎么说(C11,5.1.2.3/2):



他们都是程序运行时的概念!

参考链接:

Sequence Points in C》《C sequence points

Sequence points》《Sequence points...

C语言序列点浅析》(该博客的其它文章要看)

C/C++中的序列点

C语言中的序列点

谈谈C语言中的序列点

序列点在C语言表达式求值中的功用

C语言的黑暗角落: 副作用与序列点

关于Sequence point与Undefined behaviour之间的关系

Non-determinism and sequence points in C

C/C++中的side effect(负效应) 和sequence point(序列点)

C语言 side effect 和 sequence point

Sequence Points and Expression Evaluation in C++

Order of evaluation》《Order of evaluation

sequence point》《Sequence point

Sequence points》《Sequence points》《Sequence Points

A Guide to Undefined Behavior in C and C++

What are the sequence points in a full expression?

C语言的副作用》《Sequence Points and Expression Evaluation in C++ 》

Undefined behavior and sequence points

C Programming/Side effects and sequence points

A finer-grained specification of sequencing

C sequence point explained

C/C++中的序列点》《C/C++ 的序列点

A finer-grained specification of sequencing》《C language mysterious, what are these goods.

C11&C++11的赋值相关表达式求值

EXP44-C. Do not rely on side effects in operands to sizeof, _Alignof, or _Generic》《Sequence points

序列点在C语言表达式求值中的作用》《Sequence point

C pointer aliasing violations and aggressive compiler optimizations.

Solving the gcc 4.4 strict aliasing problems

C99 Strict Aliasing Rules and Packed Streams》《Strict aliasing and buffer handling

Memory pools, object lifetimes and strict aliasing

Lesser known consequences of C's "strict aliasing" rules (aka "a lot of C code is broken under strict aliasing")

Effective types and aliasing 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值