Qa·C Release Notes

Total Page:16

File Type:pdf, Size:1020Kb

Qa·C Release Notes RELEASE NOTES QA·C 9.4.1 February, 2018 Documentation Version 1.3 IMPORTANT NOTICE DISCLAIMER OF WARRANTY This document should only be used in conjunction with QA·C 9.4.1. Programming Research Ltd. have taken due care in preparing this document which it has endeavored to ensure is accurate at the time of printing. However, no liability can be accepted for errors or omissions; nor should the document be considered as an expressed or implied warranty of accuracy or completeness, fitness for a particular purpose, or that the products described perform as specified within. COPYRIGHT NOTICE All rights reserved. No part of this document may be reproduced, stored in a retrieval system of any nature, or transmitted in any form or by any means, including photocopying and recording, without the prior written permission of Programming Research Ltd., the copyright owner. If any unauthorized acts are carried out in relation to this copyrighted work, a civil claim for damages may be made and/or a criminal prosecution may result. Copyright ©Programming Research Ltd. 2018 TRADEMARKS PRQA, the PRQA logo, QA·C, QA·C++ and High Integrity C++ (HIC++) are trademarks of Programming Research Ltd. "MISRA", "MISRA C" and "MISRA C++" are registered trademarks of HORIBA MIRA Lim- ited, held on behalf of the MISRA Consortium. "AUTOSAR" is a registered trademark of AUTOSAR GBR, held on behalf of the AU- TOSAR Development Partnership. Yices is a registered trademark of SRI International. Windows is a registered trademark of Microsoft Corporation. RELEASE NOTES : QA·C 9.4.1 Page i Programming Research Ltd. CONTACTING PROGRAMMING RESEARCH LTD For technical support, contact your nearest Programming Research Ltd. authorized dis- tributor or, alternatively, the Programming Research Ltd. head office as follows: by telephone on +44 (0) 1932 888 080 by fax on +44 (0) 1932 888 081 or by webpage: www.prqa.com/services/contact-support/ RELEASE NOTES : QA·C 9.4.1 Page ii Programming Research Ltd. Contents 1 Introduction1 2 QA·C Changes Overview2 2.1 Functional Changes in QA·C 9.4.1.......................2 2.1.1 Support for C99 Hexadecimal Floating Point.............2 2.1.2 Enhanced Analysis of Missing Const.................2 2.2 Functional Changes in QA·C 9.4.0.......................3 2.2.1 Analysis of Commented Out Code...................3 2.2.2 Other Changes in QA·C 9.4.0.....................4 2.3 Functional Changes in QA·C 9.3.0.......................4 2.3.1 MISRA C 2012 Improvements.....................4 2.3.2 Configuration Changes.........................4 2.3.3 End of line continuation character...................4 2.4 Functional Changes in QA·C 9.2.0.......................5 2.4.1 Full Support for Designated Initializers................5 2.4.1.1 Designated array members resulting in out of bounds..5 2.4.1.2 Overwritten initializers....................6 2.4.1.3 Diagnostic Locations in Initializers.............6 2.4.2 Dataflow.................................7 2.4.2.1 Header Function Analysis..................7 2.4.3 Metric Improvements..........................7 2.4.3.1 Ticket 24385.........................7 2.4.3.2 Ticket 24386.........................9 2.4.3.3 Ticket 24387.........................9 2.4.4 Known Issues..............................9 2.4.4.1 Use of -extensions Option with Assembly.........9 2.5 Functional Changes in QA·C 9.1.1....................... 10 2.5.1 Justification for Comment Based Suppressions............ 10 2.6 Functional Changes in QA·C 9.1.0....................... 10 2.6.1 Messages Location Changes...................... 10 2.6.2 Support for GCC language extensions................ 11 2.6.2.1 Nested Functions...................... 11 2.6.2.2 Statement Expressions................... 11 2.6.3 Dataflow................................. 12 2.6.3.1 Query Timeout Message.................. 12 2.6.3.2 Buffer Overflow Checking.................. 13 2.6.3.3 Parameters Declared with Array Syntax.......... 13 3 QA·C Messages 14 3.1 Messages for QA·C 9.4.1............................ 14 3.1.1 New Messages............................. 14 3.1.2 Messages with Modified Behavior................... 14 RELEASE NOTES : QA·C 9.4.1 Page iii Programming Research Ltd. 3.2 Messages for QA·C 9.4.0............................ 41 3.2.1 New Messages............................. 41 3.2.2 Messages with Modified Behavior................... 48 3.2.3 Message Text Changes......................... 118 3.3 Messages for QA·C 9.3.1............................ 120 3.3.1 Messages with Modified Behavior................... 120 3.4 Messages for QA·C 9.3.0............................ 125 3.4.1 New Messages............................. 125 3.4.2 Removed Messages.......................... 151 3.4.3 Messages with Modified Behavior................... 153 3.4.4 Message Text Changes......................... 362 3.5 Messages for QA·C 9.2.0............................ 364 3.5.1 New Messages............................. 364 3.5.2 Messages with Modified Behavior................... 372 3.5.3 Message Text Changes......................... 450 3.6 Messages for QA·C 9.1.1............................ 451 3.6.1 New Messages............................. 451 3.6.2 Messages with Modified Behavior................... 451 3.7 Messages for QA·C 9.1.0............................ 454 3.7.1 New Messages............................. 454 3.7.2 Messages with Modified Behavior................... 468 4 QA·C Ticket Summary 486 4.1 Ticket Summary for QA·C 9.4.1......................... 486 4.2 Ticket Summary for QA·C 9.4.0......................... 487 4.3 Ticket Summary for QA·C 9.3.1......................... 502 4.4 Ticket Summary for QA·C 9.3.0......................... 504 4.5 Ticket Summary for QA·C 9.2.0......................... 523 4.6 Ticket Summary for QA·C 9.1.1......................... 541 4.7 Ticket Summary for QA·C 9.1.0......................... 542 RELEASE NOTES : QA·C 9.4.1 Page iv Programming Research Ltd. 1 Introduction Version 9.4.1 of QA·C is a patch release. This document provides information on the feature additions and fixes made in the re- lease. RELEASE NOTES : QA·C 9.4.1 Page 1 Programming Research Ltd. 2 QA·C Changes Overview 2.1 Functional Changes in QA·C 9.4.1 2.1.1 Support for C99 Hexadecimal Floating Point ISO:C99 allows that floating constants can be expressed in hexadecimal representation in addition to decimal representation. In line with this, QA·C is now able to parse the syntax of floating point constants. QA·C also generates a new C99 language extension message (1076) to report the use of hexadecimal floating point constants, for example: /*PRQA S 1076 ++*/ double val = 0x1.1p4; /* Hexadecimal floating constant */ 2.1.2 Enhanced Analysis of Missing Const The QA·C 9.4.1 type system has been reworked to allow for better analysis of missing const, specifically through the analysis of pointer to types. Specifically, QA·C is now able to identify pointers/pointer variables which exist in block scope and point to non-const- qualified types, but which could instead point to const-qualified types. QA·C also generates new messages (3678, 3679 and 3695) to indicate when a local or static pointer variable could be declared with increased const-qualification, for example: /*PRQA S 0-9999 ++*/ /*PRQA S 3678 --*/ void foo (int * x) { int * y; /* No message */ int * z; /* Message 3678 - could be 'int const *' */ int * w; /* Message 3678 - could be 'int const *' */ y = x; z = y; w = z; * y = '\0'; } void take_ip (int * p); void take_icp (int * cp); void take_ipp (int ** pp); RELEASE NOTES : QA·C 9.4.1 Page 2 Programming Research Ltd. void bar (int * x) { int * s = x; /* No message */ int * t = x; /* Message 3678 - could be 'int const *' */ int * u = x; /* No message */ take_ip (s); take_icp (t); take_ipp (&u); } void baz (int i) { int arr[] = { 1, 2, 3, 4, 5 }; /* Message 3678 - could be 'int const [5]' */ return arr[i]; } Note: There are known false positive instances of 3678, 3679 and 3695, where typedefs are used to build derived types. For example: typedef int Num; void incorrect (Num x) { Num a[5] = { x }; // false positive 3678 Num * p = a; p[1] = 6; } 2.2 Functional Changes in QA·C 9.4.0 2.2.1 Analysis of Commented Out Code QA·C 9.4.0 provides the analysis of commented out code, for both line and block com- ments, by tokenizing comments and using a triplet-based algorithm (described in the message help) to compare the comments against a table of "common code sequences" gathered from real-world, standard-compliant projects. While TU (Translation Unit) code is being parsed, this table is dynamically updated with the sequences of tokens found in the code, and the token statistics for the project currently being parsed are updated accordingly. The configuration option -po comment::dynamic_statistics allows you to control this update behavior. The option is enabled by default, being set to -po comment::dynamic_statistics+. RELEASE NOTES : QA·C 9.4.1 Page 3 Programming Research Ltd. If you wish to disable the behavior, for example because you wish to ensure that the same table of "common code sequences" is used for every single TU, then simply set the option to -po comment::dynamic_statistics-. 2.2.2 Other Changes in QA·C 9.4.0 There is improved signal to noise ratio in the analysis of resources. In addition, QA·C 9.4.0 addresses several critical failures. 2.3 Functional Changes in QA·C 9.3.0 2.3.1 MISRA C 2012 Improvements This release includes many improvements to the coverage of MISRA C 2012, specifically relating to depth of analysis. Detailed information relating to messages added, removed and changed can be found in the QA·C Messages section. 2.3.2 Configuration Changes 2.3.3 End of line continuation character QA·C formerly treated \new-line as a continuation character. However, this behavior could have resulted in configuration problems that were hard to identify.
Recommended publications
  • Truffle/C Interpreter
    JOHANNES KEPLER UNIVERSITAT¨ LINZ JKU Faculty of Engineering and Natural Sciences Truffle/C Interpreter Master’s Thesis submitted in partial fulfillment of the requirements for the academic degree Diplom-Ingenieur in the Master’s Program Computer Science Submitted by Manuel Rigger, BSc. At the Institut f¨urSystemsoftware Advisor o.Univ.-Prof. Dipl.-Ing. Dr.Dr.h.c. Hanspeter M¨ossenb¨ock Co-advisor Dipl.-Ing. Lukas Stadler Dipl.-Ing. Dr. Thomas W¨urthinger Xiamen, April 2014 Contents I Contents 1 Introduction 3 1.1 Motivation . .3 1.2 Goals and Scope . .4 1.3 From C to Java . .4 1.4 Structure of the Thesis . .6 2 State of the Art 9 2.1 Graal . .9 2.2 Truffle . 10 2.2.1 Rewriting and Specialization . 10 2.2.2 Truffle DSL . 11 2.2.3 Control Flow . 12 2.2.4 Profiling and Inlining . 12 2.2.5 Partial Evaluation and Compilation . 12 2.3 Clang . 13 3 Architecture 14 3.1 From Clang to Java . 15 3.2 Node Construction . 16 3.3 Runtime . 16 4 The Truffle/C File 17 4.1 Truffle/C File Format Goals . 17 4.2 Truffle/C File Format 1 . 19 4.2.1 Constant Pool . 19 4.2.2 Function Table . 20 4.2.3 Functions and Attributes . 20 4.3 Truffle/C File Considerations and Comparison . 21 4.3.1 Java Class File and Truffle/C File . 21 4.3.2 ELF and Truffle/C File . 22 4.4 Clang Modification Truffle/C File . 23 Contents II 5 Truffle/C Data Types 25 5.1 Data Type Hierarchy: Boxing, Upcasts and Downcasts .
    [Show full text]
  • Contents of Lecture 4: Declarations
    Contents of Lecture 4: Declarations Implicint int Storage class specifiers Type specifiers Enumeration specifiers Type qualifiers Jonas Skeppstedt ([email protected]) Lecture 4 2014 1 / 39 Now obsolete: implicit int Sometimes you can see code such as: main() // invalid { } or even: #include <stdio.h> count; // invalid float x; In earlier versions of C one could skip the type, which then became int, and is called implicit int. Calling a function before its declaration also set its return type to int. It’s invalid C so don’t use it — but compilers often allow it... Jonas Skeppstedt ([email protected]) Lecture 4 2014 2 / 39 Storage class specifiers Last lecture we discussed the different kinds of storage durations. Now we will see how to specify some of them explicitly. Dynamic (important) and temporary (less important) storage duration are not specified by the programmer using any particular syntax but defined by the standard. The storage class specifiers are: typedef extern static _Thread_local auto register Of these typedef does not refer to any kind of storage duration — instead it introduces another name of a type and not a new type: typedef int num_t; int* p; num_t* q; p = q; // valid since p and q have the same type. Jonas Skeppstedt ([email protected]) Lecture 4 2014 3 / 39 Storage class specifiers: static at file scope static int count; /∗ initialized to zero. ∗/ static void init(void) { /∗ Do some initializations ... ∗/ } Used to make an identifier invisible outside the source file With static at file scope, there is no risk of name conflicts with other files.
    [Show full text]
  • ACCU 2015 “New” Features in C
    "New" Features in C ACCU 2015 “New” Features in C Dan Saks Saks & Associates www.dansaks.com 1 Abstract The first international standard for the C programming language was C90. Since then, two newer standards have been published, C99 and C11. C99 introduced a significant number of new features. C11 introduced a few more, some of which have been available in compilers for some time. Curiously, many of these added features don’t seem to have caught on. Many C programmers still program in C90. This session explains many of these “new” features, including declarations in for-statements, typedef redefinitions, inline functions, complex arithmetic, extended integer types, variable- length arrays, flexible array members, compound literals, designated initializers, restricted pointers, type-qualified array parameters, anonymous structures and unions, alignment support, non-returning functions, and static assertions. 2 Copyright © 2015 by Daniel Saks 1 "New" Features in C About Dan Saks Dan Saks is the president of Saks & Associates, which offers training and consulting in C and C++ and their use in developing embedded systems. Dan has written columns for numerous print publications including The C/C++ Users Journal , The C++ Report , Software Development , and Embedded Systems Design . He currently writes the online “Programming Pointers” column for embedded.com . With Thomas Plum, he wrote C++ Programming Guidelines , which won a 1992 Computer Language Magazine Productivity Award . He has also been a Microsoft MVP. Dan has taught thousands of programmers around the world. He has presented at conferences such as Software Development and Embedded Systems , and served on the advisory boards for those conferences.
    [Show full text]
  • XL C/C++: Language Reference About This Document
    IBM XL C/C++ for Linux, V16.1.1 IBM Language Reference Version 16.1.1 SC27-8045-01 IBM XL C/C++ for Linux, V16.1.1 IBM Language Reference Version 16.1.1 SC27-8045-01 Note Before using this information and the product it supports, read the information in “Notices” on page 63. First edition This edition applies to IBM XL C/C++ for Linux, V16.1.1 (Program 5765-J13, 5725-C73) and to all subsequent releases and modifications until otherwise indicated in new editions. Make sure you are using the correct edition for the level of the product. © Copyright IBM Corporation 1998, 2018. US Government Users Restricted Rights – Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. Contents About this document ......... v Chapter 4. IBM extension features ... 11 Who should read this document........ v IBM extension features for both C and C++.... 11 How to use this document.......... v General IBM extensions ......... 11 How this document is organized ....... v Extensions for GNU C compatibility ..... 15 Conventions .............. v Extensions for vector processing support ... 47 Related information ........... viii IBM extension features for C only ....... 56 Available help information ........ ix Extensions for GNU C compatibility ..... 56 Standards and specifications ........ x Extensions for vector processing support ... 58 Technical support ............ xi IBM extension features for C++ only ...... 59 How to send your comments ........ xi Extensions for C99 compatibility ...... 59 Extensions for C11 compatibility ...... 59 Chapter 1. Standards and specifications 1 Extensions for GNU C++ compatibility .... 60 Chapter 2. Language levels and Notices .............. 63 language extensions ......... 3 Trademarks .............
    [Show full text]
  • C-STAT® Static Analysis Guide
    C-STAT® Static Analysis Guide CSTAT-14 COPYRIGHT NOTICE © 2015–2021 IAR Systems AB and Synopsys, Inc. No part of this document may be reproduced without the prior written consent of IAR Systems AB. The software described in this document is furnished under a license and may only be used or copied in accordance with the terms of such a license. This publication incorporates portions of the Technical Report, “SEI CERT C Coding Standard Rules for Developing Safe, Reliable, and Secure Systems 2016 Edition,” by CERT. © 2016 Carnegie Mellon University, with special permission from its Software Engineering Institute. DISCLAIMERS The information in this document is subject to change without notice and does not represent a commitment on any part of IAR Systems. While the information contained herein is assumed to be accurate, IAR Systems assumes no responsibility for any errors or omissions. In no event shall IAR Systems, its employees, its contractors, or the authors of this document be liable for special, direct, indirect, or consequential damage, losses, costs, charges, claims, demands, claim for lost profits, fees, or expenses of any nature or kind. Any material of Carnegie Mellon University and/or its software engineering institute contained herein is furnished on an “as-is” basis. Carnegie Mellon University makes no warranties of any kind, either expressed or implied, as to any matter including, but not limited to, warranty of fitness for purpose or merchantability, exclusivity, or results obtained from use of the material. Carnegie Mellon University does not make any warranty of any kind with respect to freedom from patent, trademark, or copyright infringement.
    [Show full text]
  • Vbcc Compiler System
    vbcc compiler system Volker Barthelmann i Table of Contents 1 General :::::::::::::::::::::::::::::::::::::::::: 1 1.1 Introduction ::::::::::::::::::::::::::::::::::::::::::::::::::: 1 1.2 Legal :::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 1 1.3 Installation :::::::::::::::::::::::::::::::::::::::::::::::::::: 2 1.3.1 Installing for Unix::::::::::::::::::::::::::::::::::::::::: 3 1.3.2 Installing for DOS/Windows::::::::::::::::::::::::::::::: 3 1.3.3 Installing for AmigaOS :::::::::::::::::::::::::::::::::::: 3 1.4 Tutorial :::::::::::::::::::::::::::::::::::::::::::::::::::::::: 5 2 The Frontend ::::::::::::::::::::::::::::::::::: 7 2.1 Usage :::::::::::::::::::::::::::::::::::::::::::::::::::::::::: 7 2.2 Configuration :::::::::::::::::::::::::::::::::::::::::::::::::: 8 3 The Compiler :::::::::::::::::::::::::::::::::: 11 3.1 General Compiler Options::::::::::::::::::::::::::::::::::::: 11 3.2 Errors and Warnings :::::::::::::::::::::::::::::::::::::::::: 15 3.3 Data Types ::::::::::::::::::::::::::::::::::::::::::::::::::: 15 3.4 Optimizations::::::::::::::::::::::::::::::::::::::::::::::::: 16 3.4.1 Register Allocation ::::::::::::::::::::::::::::::::::::::: 18 3.4.2 Flow Optimizations :::::::::::::::::::::::::::::::::::::: 18 3.4.3 Common Subexpression Elimination :::::::::::::::::::::: 19 3.4.4 Copy Propagation :::::::::::::::::::::::::::::::::::::::: 20 3.4.5 Constant Propagation :::::::::::::::::::::::::::::::::::: 20 3.4.6 Dead Code Elimination::::::::::::::::::::::::::::::::::: 21 3.4.7 Loop-Invariant Code Motion
    [Show full text]
  • Coverity Support for SEI CERT C, C++, and Java Coding Standards
    Coverity Support for SEI CERT C, C++, and Java Coding Standards Ensure the safety, The SEI CERT C, C++, and Oracle Java Coding Standards are lists of rules and reliability, and security recommendations for writing secure code in the C, C++, and Java programming languages They represent an important milestone in introducing best practices for of software written in C, ensuring the safety, reliability, security, and integrity of software written in C/C++ and C++, and Java Java Notably, the standards are designed to be enforceable by software code analyzers using static analysis techniques This greatly reduces the cost of compliance by way of automation Adhering to coding standards is a crucial step in establishing best coding practices Standards adherence is particularly important in safety-critical, high-impact industries, such as automotive, medical, and networking Software defects in products coming from these industries manifest themselves physically and tangibly—often with life- threatening consequences Synopsys provides a comprehensive solution for the SEI CERT C/C++ Coding Standards rules, along with high-impact SEI CERT Oracle Java Coding Standards (online version) rules and SEI CERT C Coding Standard recommendations (online version) Coverity static analysis implements the Rules category within the CERT C/ C++ standards, high-impact CERT Java L1 rules, and methods for managing violations and reporting on them Coverity also supports some of the best practices from the Recommendations category for the CERT C standard Acknowledgement
    [Show full text]
  • In Using the GNU Compiler Collection (GCC)
    Using the GNU Compiler Collection For gcc version 6.1.0 (GCC) Richard M. Stallman and the GCC Developer Community Published by: GNU Press Website: http://www.gnupress.org a division of the General: [email protected] Free Software Foundation Orders: [email protected] 51 Franklin Street, Fifth Floor Tel 617-542-5942 Boston, MA 02110-1301 USA Fax 617-542-2652 Last printed October 2003 for GCC 3.3.1. Printed copies are available for $45 each. Copyright c 1988-2016 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with the Invariant Sections being \Funding Free Software", the Front-Cover Texts being (a) (see below), and with the Back-Cover Texts being (b) (see below). A copy of the license is included in the section entitled \GNU Free Documentation License". (a) The FSF's Front-Cover Text is: A GNU Manual (b) The FSF's Back-Cover Text is: You have freedom to copy and modify this GNU Manual, like GNU software. Copies published by the Free Software Foundation raise funds for GNU development. i Short Contents Introduction ::::::::::::::::::::::::::::::::::::::::::::: 1 1 Programming Languages Supported by GCC ::::::::::::::: 3 2 Language Standards Supported by GCC :::::::::::::::::: 5 3 GCC Command Options ::::::::::::::::::::::::::::::: 9 4 C Implementation-Defined Behavior :::::::::::::::::::: 373 5 C++ Implementation-Defined Behavior ::::::::::::::::: 381 6 Extensions to
    [Show full text]
  • TR0109 TSK3000 Embedded Tools Reference
    TSK3000 Embedded Tools Reference TR0109 Nov 22, 2010 Software, hardware, documentation and related materials: Copyright E 2010 Altium Limited. All Rights Reserved. The material provided with this notice is subject to various forms of national and international intellectual property protection, including but not limited to copyright protection. You have been granted a non-exclusive license to use such material for the purposes stated in the end-user license agreement governing its use. In no event shall you reverse engineer, decompile, duplicate, distribute, create derivative works from or in any way exploit the material licensed to you except as expressly permitted by the governing agreement. Failure to abide by such restrictions may result in severe civil and criminal penalties, including but not limited to fines and imprisonment. Provided, however, that you are permitted to make one archival copy of said materials for back up purposes only, which archival copy may be accessed and used only in the event that the original copy of the materials is inoperable. Altium, Altium Designer, Board Insight, DXP, Innovation Station, LiveDesign, NanoBoard, NanoTalk, OpenBus, P-CAD, SimCode, Situs, TASKING, and Topological Autorouting and their respective logos are trademarks or registered trademarks of Altium Limited or its subsidiaries. All other registered or unregistered trademarks referenced herein are the property of their respective owners and no trademark rights to the same are claimed. v8.0 31/3/08 Table of Contents Table of Contents C Language 1-1 1.1 Introduction . .. .. .. .. .. .. 1-1 1.2 Data Types . .. .. .. .. .. .. 1-2 1.2.1 Changing the Alignment: __unaligned, __packed__ and __align().
    [Show full text]
  • Using the GNU Compiler Collection
    Using the GNU Compiler Collection For gcc version 4.2.4 Richard M. Stallman and the GCC Developer Community Published by: GNU Press Website: www.gnupress.org a division of the General: [email protected] Free Software Foundation Orders: [email protected] 51 Franklin Street, Fifth Floor Tel 617-542-5942 Boston, MA 02110-1301 USA Fax 617-542-2652 Last printed October 2003 for GCC 3.3.1. Printed copies are available for $45 each. Copyright c 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with the Invariant Sections being “GNU General Public License” and “Funding Free Software”, the Front-Cover texts being (a) (see below), and with the Back-Cover Texts being (b) (see below). A copy of the license is included in the section entitled “GNU Free Documentation License”. (a) The FSF’s Front-Cover Text is: A GNU Manual (b) The FSF’s Back-Cover Text is: You have freedom to copy and modify this GNU Manual, like GNU software. Copies published by the Free Software Foundation raise funds for GNU development. i Short Contents Introduction ............................................. 1 1 Programming Languages Supported by GCC ............... 3 2 Language Standards Supported by GCC .................. 5 3 GCC Command Options ............................... 7 4 C Implementation-defined behavior ..................... 215 5 Extensions to the C Language Family ................... 223 6 Extensions to the C++ Language .....................
    [Show full text]
  • 15-122: Principles of Imperative Computation Recitation 23 The
    15-122: Principles of Imperative Computation Recitation 23 Section C November 16, 2012 The switch/case construct Given int expression e, constants c1, c2, ..., cn, the following are roughly equivalent: switch (e) { int x = e; case c1: if (x == c1) <statement 1> <statement 1> break; else if (x == c2) <statement 2> case c2: ... <statement 2> else if (x == cn) break; <statement n> else ... <default statement> case cn: <statement n> break; default: <default statement> break; } Note: the 'break;' statements in the cases of the switch are important: without a 'break;', control falls through to the following case. This design choice can easily lead to unexpected behaviors. Consider: switch (x % 2) { case 0: printf("x is even\n"); case 1: printf("x" is odd\n"); } You can make hella elegant code sometimes by exploiting the fallthrough behavior of cases: switch(x) { case 1: case 4: case 9: { int sx = isqrt(x); printf("sqrt(x) = %d\n", sx); break; } default: printf("not a perfect square...\n"); } The entire main loop of your VM will be one big switch statement. Be wary of fallthrough! 1 Structs that aren't pointers In C0 and in much of our C programming, we have accessed structs through pointers almost exclusively. typedef struct stack * stack; struct stack { list top; }; ... stack S = stack_new(); ... ... S->top ... Sometimes it's convenient to access structs directly, though, like when they're stored in an array. To access a field f of a struct expression e, one uses the syntax 'e.f'. stack stack_array[] = ... ... stack_array[i].top ... In fact, the familiar notation 'p->f' for accessing a struct field through a pointer p is just syntactic sugar for '(*p).f', and since array indexing is just syntactic sugar for pointer arithmetic, the above expression really amounts to '(*(stack_array+i)).top', or (stack_array+i)->top.
    [Show full text]
  • C Programming
    C Programming en.wikibooks.org November 24, 2013 On the 28th of April 2012 the contents of the English as well as German Wikibooks and Wikipedia projects were licensed under Creative Commons Attribution-ShareAlike 3.0 Unported license. A URI to this license is given in the list of figures on page 273. If this document is a derived work from the contents of one of these projects and the content was still licensed by the project under this license at the time of derivation this document has to be licensed under the same, a similar or a compatible license, as stated in section 4b of the license. The list of contributors is included in chapter Contributors on page 265. The licenses GPL, LGPL and GFDL are included in chapter Licenses on page 277, since this book and/or parts of it may or may not be licensed under one or more of these licenses, and thus require inclusion of these licenses. The licenses of the figures are given in the list of figures on page 273. This PDF was generated by the LATEX typesetting software. The LATEX source code is included as an attachment (source.7z.txt) in this PDF file. To extract the source from the PDF file, you can use the pdfdetach tool including in the poppler suite, or the http://www. pdflabs.com/tools/pdftk-the-pdf-toolkit/ utility. Some PDF viewers may also let you save the attachment to a file. After extracting it from the PDF file you have to rename it to source.7z.
    [Show full text]