在好例子网,分享、交流、成长!
您当前所在位置:首页C/C++ 开发实例Android手机应用开发 → SEI CERT C++ Coding Standard by Aaron Ballman (z-lib.org).pdf

SEI CERT C++ Coding Standard by Aaron Ballman (z-lib.org).pdf

Android手机应用开发

下载此实例
  • 开发语言:C/C++
  • 实例大小:3.04M
  • 下载次数:7
  • 浏览次数:295
  • 发布时间:2020-12-09
  • 实例类别:Android手机应用开发
  • 发 布 人:robin23
  • 文件格式:.pdf
  • 所需积分:2
 相关标签: coding c++ aar c++ and

实例介绍

SEI CERT C Coding Standard by Aaron Ballman (z-lib.org)

from clipboard

【文件目录】

Table of Contents
1 Introduction 1
1.1 Scope 1
1.2 Audience 3
1.3 Usage 3
1.4 How this Coding Standard Is Organized 4
1.5 Relation to the CERT C Coding Standard 9
1.6 Rules Versus Recommendations 10
1.7 Tool Selection and Validation 11
1.8 Conformance Testing 12
1.9 Development Process 13
1.10 System Qualities 14
1.11 Automatically Generated Code 14
1.12 Government Regulations 15
1.13 Acknowledgments 17
2 Declarations and Initialization (DCL) 18
2.1 DCL50-CPP. Do not define a C-style variadic function 18
2.2 DCL51-CPP. Do not declare or define a reserved identifier 22
2.3 DCL52-CPP. Never qualify a reference type with const or volatile 28
2.4 DCL53-CPP. Do not write syntactically ambiguous declarations 31
2.5 DCL54-CPP. Overload allocation and deallocation functions as a pair in the
same scope 37
2.6 DCL55-CPP. Avoid information leakage when passing a class object across a trust
boundary 41
2.7 DCL56-CPP. Avoid cycles during initialization of static objects 51
2.8 DCL57-CPP. Do not let exceptions escape from destructors or deallocation functions 57
2.9 DCL58-CPP. Do not modify the standard namespaces 63
2.10 DCL59-CPP. Do not define an unnamed namespace in a header file 69
2.11 DCL60-CPP. Obey the one-definition rule 76
3 Expressions (EXP) 83
3.1 EXP50-CPP. Do not depend on the order of evaluation for side effects 83
3.2 EXP51-CPP. Do not delete an array through a pointer of the incorrect type 90
3.3 EXP52-CPP. Do not rely on side effects in unevaluated operands 92
3.4 EXP53-CPP. Do not read uninitialized memory 96
3.5 EXP54-CPP. Do not access an object outside of its lifetime 101
3.6 EXP55-CPP. Do not access a cv-qualified object through a cv-unqualified type 112
3.7 EXP56-CPP. Do not call a function with a mismatched language linkage 117
3.8 EXP57-CPP. Do not cast or delete pointers to incomplete classes 120
SEI CERT C   CODING STANDARD (2016 EDITION) | V01 ii
Software Engineering Institute | Carnegie Mellon University
[DISTRIBUTION STATEMENT A] Approved for public release and unlimited distribution.
3.9 EXP58-CPP. Pass an object of the correct type to va_start 126
3.10 EXP59-CPP. Use offsetof() on valid types and members 130
3.11 EXP60-CPP. Do not pass a nonstandard-layout type object across execution
boundaries 134
3.12 EXP61-CPP. A lambda object must not outlive any of its reference captured objects 139
3.13 EXP62-CPP. Do not access the bits of an object representation that are not part
of the object’s value representation 142
3.14 EXP63-CPP. Do not rely on the value of a moved-from object 147
4 Integers (INT) 153
4.1 INT50-CPP. Do not cast to an out-of-range enumeration value 153
5 Containers (CTR) 157
5.1 CTR50-CPP. Guarantee that container indices and iterators are within the valid range 157
5.2 CTR51-CPP. Use valid references, pointers, and iterators to reference elements of a
container 163
5.3 CTR52-CPP. Guarantee that library functions do not overflow 170
5.4 CTR53-CPP. Use valid iterator ranges 174
5.5 CTR54-CPP. Do not subtract iterators that do not refer to the same container 177
5.6 CTR55-CPP. Do not use an additive operator on an iterator if the result would overflow 182
5.7 CTR56-CPP. Do not use pointer arithmetic on polymorphic objects 184
5.8 CTR57-CPP. Provide a valid ordering predicate 189
5.9 CTR58-CPP. Predicate function objects should not be mutable 193
6 Characters and Strings (STR) 198
6.1 STR50-CPP. Guarantee that storage for strings has sufficient space for character
data and the null terminator 198
6.2 STR51-CPP. Do not attempt to create a std::string from a null pointer 201
6.3 STR52-CPP. Use valid references, pointers, and iterators to reference elements of a
basic_string 205
6.4 STR53-CPP. Range check element access 209
7 Memory Management (MEM) 213
7.1 MEM50-CPP. Do not access freed memory 213
7.2 MEM51-CPP. Properly deallocate dynamically allocated resources 220
7.3 MEM52-CPP. Detect and handle memory allocation errors 233
7.4 MEM53-CPP. Explicitly construct and destruct objects when manually managing
object lifetime 238
7.5 MEM54-CPP. Provide placement new with properly aligned pointers to sufficient
storage capacity 243
7.6 MEM55-CPP. Honor replacement dynamic storage management requirements 249
7.7 MEM56-CPP. Do not store an already-owned pointer value in an unrelated smart
pointer 253
7.8 MEM57-CPP. Avoid using default operator new for over-aligned types 258
SEI CERT C   CODING STANDARD (2016 EDITION) | V01 iii
Software Engineering Institute | Carnegie Mellon University
[DISTRIBUTION STATEMENT A] Approved for public release and unlimited distribution.
8 Input Output (FIO) 261
8.1 FIO50-CPP. Do not alternately input and output from a file stream without an intervening
positioning call 261
8.2 FIO51-CPP. Close files when they are no longer needed 264
9 Exceptions and Error Handling (ERR) 267
9.1 ERR50-CPP. Do not abruptly terminate the program 267
9.2 ERR51-CPP. Handle all exceptions 273
9.3 ERR52-CPP. Do not use setjmp() or longjmp() 276
9.4 ERR53-CPP. Do not reference base classes or class data members in a constructor or
destructor function-try-block handler 280
9.5 ERR54-CPP. Catch handlers should order their parameter types from most derived to
least derived 282
9.6 ERR55-CPP. Honor exception specifications 284
9.7 ERR56-CPP. Guarantee exception safety 288
9.8 ERR57-CPP. Do not leak resources when handling exceptions 292
9.9 ERR58-CPP. Handle all exceptions thrown before main() begins executing 298
9.10 ERR59-CPP. Do not throw an exception across execution boundaries 303
9.11 ERR60-CPP. Exception objects must be nothrow copy constructible 307
9.12 ERR61-CPP. Catch exceptions by lvalue reference 312
9.13 ERR62-CPP. Detect errors when converting a string to a number 316
10 Object Oriented Programming (OOP) 320
10.1 OOP50-CPP. Do not invoke virtual functions from constructors or destructors 320
10.2 OOP51-CPP. Do not slice derived objects 325
10.3 OOP52-CPP. Do not delete a polymorphic object without a virtual destructor 333
10.4 OOP53-CPP. Write constructor member initializers in the canonical order 336
10.5 OOP54-CPP. Gracefully handle self-copy assignment 340
10.6 OOP55-CPP. Do not use pointer-to-member operators to access nonexistent
members 345
10.7 OOP56-CPP. Honor replacement handler requirements 350
10.8 OOP57-CPP. Prefer special member functions and overloaded operators to
C Standard Library functions 353
10.9 OOP58-CPP. Copy operations must not mutate the source object 360
SEI CERT C   CODING STANDARD (2016 EDITION) | V01 iv
Software Engineering Institute | Carnegie Mellon University
[DISTRIBUTION STATEMENT A] Approved for public release and unlimited distribution.
11 Concurrency (CON) 365
11.1 CON50-CPP. Do not destroy a mutex while it is locked 365
11.2 CON51-CPP. Ensure actively held locks are released on exceptional conditions 368
11.3 CON52-CPP. Prevent data races when accessing bit-fields from multiple threads 371
11.4 CON53-CPP. Avoid deadlock by locking in a predefined order 375
11.5 CON54-CPP. Wrap functions that can spuriously wake up in a loop 380
11.6 CON55-CPP. Preserve thread safety and liveness when using condition variables 385
11.7 CON56-CPP. Do not speculatively lock a non-recursive mutex that is already owned by the
calling thread 391
12 Miscellaneous (MSC) 395
12.1 MSC50-CPP. Do not use std::rand() for generating pseudorandom numbers 395
12.2 MSC51-CPP. Ensure your random number generator is properly seeded 398
12.3 MSC52-CPP. Value-returning functions must return a value from all exit paths 402
12.4 MSC53-CPP. Do not return from a function declared [[noreturn]] 405
12.5 MSC54-CPP. A signal handler must be a plain old function 407
Appendix A: Bibliography 411
Appendix B: Definitions 419
Appendix C: Related Guidelines 425
Appendix D: Risk Assessments 427

标签: coding c++ aar c++ and

实例下载地址

SEI CERT C++ Coding Standard by Aaron Ballman (z-lib.org).pdf

不能下载?内容有错? 点击这里报错 + 投诉 + 提问

好例子网口号:伸出你的我的手 — 分享

网友评论

发表评论

(您的评论需要经过审核才能显示)

查看所有0条评论>>

小贴士

感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。

  • 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
  • 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
  • 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
  • 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。

关于好例子网

本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明

;
报警