Using the GNU Compiler Collection

Total Page:16

File Type:pdf, Size:1020Kb

Using the GNU Compiler Collection Using the GNU Compiler Collection For gcc version 4.4.5 (GCC) 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, 2006, 2007, 2008 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 “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 ..................... 251 5 Extensions to the C Language Family ................... 259 6 Extensions to the C++ Language ...................... 529 7 GNU Objective-C runtime features ..................... 541 8 Binary Compatibility ................................ 547 9 gcov—a Test Coverage Program ....................... 551 10 Known Causes of Trouble with GCC .................... 559 11 Reporting Bugs ..................................... 577 12 How To Get Help with GCC .......................... 579 13 Contributing to GCC Development ..................... 581 Funding Free Software ................................... 583 The GNU Project and GNU/Linux......................... 585 GNU General Public License .............................. 587 GNU Free Documentation License ......................... 599 Contributors to GCC .................................... 607 Option Index .......................................... 623 Keyword Index ......................................... 639 iii Table of Contents Introduction ........................................ 1 1 Programming Languages Supported by GCC ................................................. 3 2 Language Standards Supported by GCC ..... 5 2.1 C language..................................................... 5 2.2 C++ language ................................................. 6 2.3 Objective-C and Objective-C++ languages ..................... 7 3 GCC Command Options ....................... 9 3.1 Option Summary............................................... 9 3.2 Options Controlling the Kind of Output ....................... 21 3.3 Compiling C++ Programs .................................... 26 3.4 Options Controlling C Dialect ................................. 27 3.5 Options Controlling C++ Dialect ............................. 31 3.6 Options Controlling Objective-C and Objective-C++ Dialects .. 40 3.7 Options to Control Diagnostic Messages Formatting ........... 44 3.8 Options to Request or Suppress Warnings ..................... 44 3.9 Options for Debugging Your Program or GCC ................. 65 3.10 Options That Control Optimization .......................... 80 3.11 Options Controlling the Preprocessor........................ 120 3.12 Passing Options to the Assembler ........................... 130 3.13 Options for Linking ......................................... 130 3.14 Options for Directory Search ................................ 134 3.15 Specifying subprocesses and the switches to pass to them .... 136 3.16 Specifying Target Machine and Compiler Version ............ 143 3.17 Hardware Models and Configurations ....................... 143 3.17.1 ARC Options .......................................... 143 3.17.2 ARM Options.......................................... 144 3.17.3 AVR Options .......................................... 148 3.17.4 Blackfin Options ....................................... 149 3.17.5 CRIS Options.......................................... 152 3.17.6 CRX Options .......................................... 153 3.17.7 Darwin Options ........................................ 154 3.17.8 DEC Alpha Options ................................... 158 3.17.9 DEC Alpha/VMS Options ............................. 162 3.17.10 FR30 Options ........................................ 162 3.17.11 FRV Options ......................................... 163 3.17.12 GNU/Linux Options .................................. 166 3.17.13 H8/300 Options....................................... 167 3.17.14 HPPA Options........................................ 167 iv Using the GNU Compiler Collection (GCC) 3.17.15 Intel 386 and AMD x86-64 Options ................... 170 3.17.16 IA-64 Options ........................................ 181 3.17.17 M32C Options ........................................ 184 3.17.18 M32R/D Options ..................................... 184 3.17.19 M680x0 Options ...................................... 186 3.17.20 M68hc1x Options ..................................... 191 3.17.21 MCore Options ....................................... 192 3.17.22 MIPS Options ........................................ 193 3.17.23 MMIX Options ....................................... 203 3.17.24 MN10300 Options .................................... 204 3.17.25 PDP-11 Options ...................................... 204 3.17.26 picoChip Options ..................................... 206 3.17.27 PowerPC Options..................................... 206 3.17.28 IBM RS/6000 and PowerPC Options .................. 206 3.17.29 S/390 and zSeries Options ............................ 218 3.17.30 Score Options......................................... 221 3.17.31 SH Options ........................................... 222 3.17.32 SPARC Options ...................................... 225 3.17.33 SPU Options ......................................... 229 3.17.34 Options for System V ................................. 231 3.17.35 V850 Options ......................................... 231 3.17.36 VAX Options ......................................... 232 3.17.37 VxWorks Options ..................................... 232 3.17.38 x86-64 Options ....................................... 233 3.17.39 i386 and x86-64 Windows Options .................... 233 3.17.40 Xstormy16 Options ................................... 234 3.17.41 Xtensa Options ....................................... 234 3.17.42 zSeries Options ....................................... 235 3.18 Options for Code Generation Conventions ................... 235 3.19 Environment Variables Affecting GCC ...................... 243 3.20 Using Precompiled Headers ................................. 246 3.21 Running Protoize ........................................... 248 4 C Implementation-defined behavior ........ 251 4.1 Translation .................................................. 251 4.2 Environment................................................. 251 4.3 Identifiers.................................................... 251 4.4 Characters ................................................... 252 4.5 Integers...................................................... 252 4.6 Floating point ............................................... 253 4.7 Arrays and pointers .......................................... 254 4.8 Hints ........................................................ 255 4.9 Structures, unions, enumerations, and bit-fields ............... 255 4.10 Qualifiers ................................................... 256 4.11 Declarators ................................................. 256 4.12 Statements ................................................. 256 4.13 Preprocessing directives ..................................... 256 4.14 Library functions ........................................... 257 v 4.15 Architecture ................................................ 257 4.16 Locale-specific behavior ..................................... 257 5 Extensions to the C Language Family ...... 259 5.1 Statements and Declarations in Expressions .................. 259 5.2 Locally Declared Labels ...................................... 260 5.3 Labels as Values ............................................. 261 5.4 Nested Functions ............................................ 262 5.5 Constructing Function Calls.................................. 264 5.6 Referring to a Type with typeof ............................. 266 5.7 Conditionals with Omitted Operands......................... 267 5.8 Double-Word Integers ........................................ 268 5.9 Complex Numbers ........................................... 268 5.10 Additional Floating Types .................................. 269 5.11 Decimal Floating Types..................................... 269 5.12 Hex Floats.................................................. 270 5.13 Fixed-Point Types .......................................... 270 5.14 Arrays of Length Zero ...................................... 271 5.15 Structures With No Members ............................... 272 5.16 Arrays of Variable Length..................................
Recommended publications
  • Open and Efficient Type Switch For
    Draft for OOPSLA 2012 Open and Efficient Type Switch for C++ Yuriy Solodkyy Gabriel Dos Reis Bjarne Stroustrup Texas A&M University Texas, USA fyuriys,gdr,[email protected] Abstract – allow for independent extensions, modular type-checking Selecting operations based on the run-time type of an object and dynamic linking. On the other, in order to be accepted is key to many object-oriented and functional programming for production code, the implementation of such a construct techniques. We present a technique for implementing open must equal or outperform all known workarounds. However, and efficient type-switching for hierarchical extensible data existing approaches to case analysis on hierarchical exten- types. The technique is general and copes well with C++ sible data types are either efficient or open, but not both. multiple inheritance. Truly open approaches rely on expensive class-membership To simplify experimentation and gain realistic prefor- testing combined with decision trees []. Efficient approaches mance using production-quality compilers and tool chains, rely on sealing either the class hierarchy or the set of func- we implement our type swich constructs as an ISO C++11 li- tions, which loses extensibility [9, 18, 44, 51]. Consider a brary. Our library-only implementation provides concise no- simple expression language: tation and outperforms the visitor design pattern, commonly exp ∶∶= val S exp + exp S exp − exp S exp ∗ exp S exp~exp used for type-casing scenarios in object-oriented programs. For many uses, it equals or outperforms equivalent code in In an object-oriented language without direct support for languages with built-in type-switching constructs, such as algebraic data types, the type representing an expression-tree OCaml and Haskell.
    [Show full text]
  • Static Reflection
    N3996- Static reflection Document number: N3996 Date: 2014-05-26 Project: Programming Language C++, SG7, Reflection Reply-to: Mat´uˇsChochl´ık([email protected]) Static reflection How to read this document The first two sections are devoted to the introduction to reflection and reflective programming, they contain some motivational examples and some experiences with usage of a library-based reflection utility. These can be skipped if you are knowledgeable about reflection. Section3 contains the rationale for the design decisions. The most important part is the technical specification in section4, the impact on the standard is discussed in section5, the issues that need to be resolved are listed in section7, and section6 mentions some implementation hints. Contents 1. Introduction4 2. Motivation and Scope6 2.1. Usefullness of reflection............................6 2.2. Motivational examples.............................7 2.2.1. Factory generator............................7 3. Design Decisions 11 3.1. Desired features................................. 11 3.2. Layered approach and extensibility...................... 11 3.2.1. Basic metaobjects........................... 12 3.2.2. Mirror.................................. 12 3.2.3. Puddle.................................. 12 3.2.4. Rubber................................. 13 3.2.5. Lagoon................................. 13 3.3. Class generators................................ 14 3.4. Compile-time vs. Run-time reflection..................... 16 4. Technical Specifications 16 4.1. Metaobject Concepts.............................
    [Show full text]
  • Function Pointer Declaration in C Typedef
    Function Pointer Declaration In C Typedef Rearing Marshall syllabized soever, he pervades his buttons very bountifully. Spineless Harcourt hybridized truncately. Niven amend unlearnedly. What context does call function declaration or not written swig code like you can call a function Understanding typedefs for function pointers in C Stack. The compiler would like structure i can use a typedef name for it points regarding which you are two invocation methods on. This a function code like an extra bytes often used as an expression in a lot of getting variables. Typedef Wikipedia. An alias for reading this website a requirement if we define a foothold into your devices and complexity and a mismatch between each c string. So group the perspective of C, it close as hate each round these lack a typedef. Not only have been using gcc certainly warns me a class member of memory cannot define an alias for a typedef? C typedef example program Complete C tutorial. CFunctionPointers. Some vendors of C products for 64-bit machines support 64-bit long ints Others fear lest too. Not knowing what would you want a pointer? The alias in memory space too complex examples, they have seen by typos. For one argument itself request coming in sharing your data type and thomas carriero for it, wasting a portability issue. In all c programming, which are communicating with. Forward declaration typedef struct a a Pointer to function with struct as. By using the custom allocator throughout your code you team improve readability and genuine the risk of introducing bugs caused by typos.
    [Show full text]
  • C++0X Type Inference
    Master seminar C++0x Type Inference Stefan Schulze Frielinghaus November 18, 2009 Abstract This article presents the new type inference features of the up- coming C++ standard. The main focus is on the keywords auto and decltype which introduce basic type inference. Their power but also their limitations are discussed in relation to full type inference of most functional programming languages. 1 Introduction Standard C++ requires explicitly a type for each variable (s. [6, § 7.1.5 clause 2]). There is no exception and especially when types get verbose it is error prone to write them. The upcoming C++ standard, from now on referenced as C++0x, includes a new functionality called type inference to circumvent this problem. Consider the following example: int a = 2; int b = 40; auto c = a + b; In this case the compiler may figure out the type of variable ‘c’ because the type of the rvalue of expression ‘a + b’ is known at compile time. In the end this means that the compiler may look up all variables and function calls of interest to figure out which type an object should have. This is done via type inference and the auto keyword. Often types get verbose when templates are used. These cases demonstrate how useful the auto keyword is. For example, in C++98 and 03 developers often use typedef to circumvent the problem of verbose types: 1 typedef std::vector<std::string> svec; ... svec v = foo(); In C++0x a typedef may be left out in favor of auto: auto v = foo(); In some cases it may reduce the overhead if someone is not familiar with a code and would therefore need to lookup all typedefs (s.
    [Show full text]
  • Modern C++ Object-Oriented Programming
    CPP Modern C++ Object-Oriented Programming ''Combine old and newer features to get the best out of the language'' Margit ANTAL 2020 C++ - Object-Oriented Programming Course content − Introduction to C++ − Object-oriented programming − Generic programming and the STL − Object-oriented design C++ - Object-Oriented Programming References − Bjarne Stroustrup, Herb Sutter, C++ Core Guidelines, 2017. rd − M. Gregoire, Professional C++, 3 edition, John Wiley & Sons, 2014. th − S. Lippman, J. Lajoie, B. E. Moo, C++ Primer, 5 edition, Addison Wesley, , 2013. th − S. Prata, C++ Primer Plus, 6 edition, Addison Wesley, 2012. − N. Josuttis, The C++ standard library. a tutorial and reference. Pearson Education. 2012. − A. Williams, C++ Concurrency in Action:Practical Multithreading. Greenwich, CT: Manning. 2012. Module 1 Introduction to C++ Introduction to C++ Content − History and evolution − Overview of the key features ● New built-in types ● Scope and namespaces ● Enumerations ● Dynamic memory: new and delete ● Smart pointers: unique_ptr, shared_ptr, weak_ptr ● Error handling with exceptions ● References ● The const modifier Introduction to C++ History and evolution − Creator: Bjarne Stroustrup 1983 − Standards: ● The first C++ standard − 1998 (C++98, major) − 2003 (C++03, minor) ● The second C++ standard − 2011 (C++11, major) – significant improvements in language and library − 2014 (C++14, minor) − 2017 (C++17, major) Introduction to C+ History and evolution − source: https://isocpp.org/std/status Introduction to C+ History and evolution − source:
    [Show full text]
  • Modern C++ Tutorial: C++11/14/17/20 on the Fly
    Modern C++ Tutorial: C++11/14/17/20 On the Fly Changkun Ou (hi[at]changkun.de) Last update: August 28, 2021 Notice The content in this PDF file may outdated, please check our website or GitHub repository for the latest book updates. License This work was written by Ou Changkun and licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. http://creativecommons.org/licenses/by-nc-nd/4.0/ 1 2 CONTENTS CONTENTS Contents Preface 8 Introduction ............................................... 8 Targets ................................................. 8 Purpose ................................................. 9 Code ................................................... 9 Exercises ................................................ 9 Chapter 01: Towards Modern C++ 9 1.1 Deprecated Features ........................................ 10 1.2 Compatibilities with C ....................................... 11 Further Readings ............................................ 13 Chapter 02: Language Usability Enhancements 13 2.1 Constants .............................................. 13 nullptr ............................................... 13 constexpr ............................................. 15 2.2 Variables and initialization .................................... 17 if-switch .............................................. 17 Initializer list ........................................... 18 Structured binding ........................................ 20 2.3 Type inference ..........................................
    [Show full text]
  • Overload Journal
    You've read the magazine, now join the association dedicated to improving your coding skills. The ACCU is a worldwide non-profit organisation run by programmers for programmers. With full ACCU membership you get: 6 copies of C Vu a year 6 copies of Overload a year The ACCU handbook Reduced rates at our acclaimed annual developers' conference Access to back issues of ACCU periodicals via How to join our web site You can join the ACCU using Access to the mentored developers projects: a our online registration form. chance for developers at all levels to improve their Go to www.accu.org and skills follow the instructions there. Mailing lists ranging from general developer discussion, through programming language use, Also available to job posting information You can now also purchase The chance to participate: write articles, comment exclusive ACCU T-shirts and on what you read, ask questions, and learn from polo shirts. See the web site your peers. for details. Basic membership entitles you to the above benefits, but without Overload. Corporate members receive five copies of each journal, and reduced conference rates for all employees. PERSONAL MEMBERSHIP CORPORATE MEMBERSHIP professionalism in programming Design: Pete Goodliffe Pete Design: STUDENT MEMBERSHIP www.accu.org OVERLOAD CONTENTS OVERLOAD 148 Overload is a publication of the ACCU December 2018 For details of the ACCU, our publications and activities, ISSN 1354-3172 visit the ACCU website: www.accu.org Editor 4 Diseconomies of Scale Frances Buontempo [email protected] Allan Kelly considers why bigger isn’t always better. Advisors Andy Balaam 6 Flip Model: A Design Pattern [email protected] Daniele Pallastrelli presents the Flip Model to Balog Pal publish dynamic, complex data to many clients [email protected] in a threadsafe manner.
    [Show full text]
  • Automatic Identification of Idiom Usage in C++ Generic Libraries
    Identification of Idiom Usage in C++ Generic Libraries Andrew Sutton, Ryan Holeman, Jonathan I. Maletic Department of Computer Science Kent State University Kent, Ohio 44242 {asutton, rholeman, jmaletic}@cs.kent.edu Abstract —A tool supporting the automatic identification of idiosyncrasies of its compilers. On the other hand, one programming idioms specific to the construction of C++ purpose of generic libraries is to provide reusable and generic libraries is presented. The goal is to assist developers adaptable libraries for application developers. Given that in understanding the complex syntactic elements of these generic libraries (via templates) are necessarily transparent libraries. Large C++ generic libraries are notorious for being (i.e., not black boxes), their usage creates a leaky abstraction . extremely difficult to comprehend due to their use of advanced The idioms used in the construction of generic libraries are language features and idiomatic nature. To facilitate leaked to more casual developers in the form of error automated identification, the idioms are equated to messages and, in some cases, compilation failures. micropatterns, which can be evaluated by a fact extractor. Our goal is to assist developers in understanding patterns These micropattern instances act as beacons for the idioms and idioms in generic libraries by providing tools to being identified. The method is applied to study a number of widely used open source C++ generic libraries. automatically identify them in source code. This helps address the “leakiness” of advanced generic and generative Keywords—C++, Templates, Generic Libraries, Emiprical programming technique by mapping these implementation- Study level idioms into more comprehensible, abstract forms. In this work, we survey a number of prevalent programming I.
    [Show full text]
  • Toward Understanding Compiler Bugs in GCC and LLVM
    ifact t * r * Comple t te A A n * te W E is s * e C n l l o D C A o * * c T u e m S s E u e S e n I R Toward Understanding Compiler Bugs t v e o d t y * s E a * a l d u e a in GCC and LLVM t Chengnian Sun Vu Le Qirun Zhang Zhendong Su Department of Computer Science, University of California, Davis, USA {cnsun, vmle, qrzhang, su}@ucdavis.edu ABSTRACT 1. INTRODUCTION Compilers are critical, widely-used complex software. Bugs Compilers are an important category of system software. in them have significant impact, and can cause serious dam- Extensive research and development efforts have been de- age when they silently miscompile a safety-critical applica- voted to increasing compilers' performance and reliability. tion. An in-depth understanding of compiler bugs can help However, it may still surprise application developers that, detect and fix them. To this end, we conduct the first em- similar to application software, production compilers also pirical study on the characteristics of the bugs in two main- contain bugs, and in fact quite many. Furthermore, com- stream compilers, GCC and LLVM. Our study is significant piler bugs impact application code, and even lead to severe in scale | it exhaustively examines about 50K bugs and damage, especially when a buggy compiler is used to compile 30K bug fix revisions over more than a decade's span. safety-critical applications. This paper details our systematic study. Summary find- Different from most of the application bugs, compiler bugs ings include: (1) In both compilers, C++ is the most buggy are difficult to recognize as they usually manifest indirectly component, accounting for around 20% of the total bugs and as application failures.
    [Show full text]
  • Effective Modern
    Effective Modern C++ Effective Modern C++ Coming to grips with C++11 and C++14 is more than a matter of familiarizing “After I learned the C++ yourself with the features they introduce (e.g., auto type declarations, basics, I then learned move semantics, lambda expressions, and concurrency support). The challenge is learning to use those features effectively—so that your how to use C++ in software is correct, efficient, maintainable, and portable. That’s where production code from this practical book comes in. It describes how to write truly great software Meyers' series of using C++11 and C++14—i.e. using modern C++. Effective C++ books. Topics include: Effective Modern C++ ■ The pros and cons of braced initialization, noexcept is the most important specifications, perfect forwarding, and smart pointermake how-to book for advice functions on key guidelines, ■ The relationships among st d::m ove, std::forward, rvalue styles, and idioms to use references, and universal references modern C++ effectively ■ Techniques for writing clear, correct, effective lambda and well. Don't own it expressions yet? Buy this one. Now. ■ How st d::at o m ic differs fromvolatile , how each should be ” —Herb Sutter used, and how they relate to C++'s concurrency API Chair of ISO C++ Standards Committee and ■ How best practices in "old" C++ programming (i.e., C++98) C++ Software Architect at Microsoft require revision for software development in modern C++ Effective Modern C++ follows the proven guideline-based, example-driven format of Scott Meyers' earlier books, but covers entirely new material. It's essential reading for every modern C++ software developer.
    [Show full text]
  • Object-Oriented Programming for Scientific Computing
    Object-Oriented Programming for Scientific Computing Dr. Ole Klein Interdisciplinary Center for Scientific Computing Heidelberg University [email protected] Winter Semester 2020/21 Dr. Ole Klein (IWR) Object-Oriented Programming Winter Semester 2020/21 1 / 277 Introduction Goals of the Lecture Prerequisites and Objectives Prerequisites • Familiarity with at least one programming language • At least procedural programming in C / C++ • Willingness to program in practice Objectives • Improved programming skills • Introduction of modern programming techniques • Strong focus on topics of relevance to Scientific Computing Dr. Ole Klein (IWR) Object-Oriented Programming Winter Semester 2020/21 2 / 277 Introduction Goals of the Lecture Course Outline General course outline: Short recapitulation of basics data types, functions, templates, classes, etc. The C++ Standard Library input/output, containers, iterators, algorithms, exceptions, etc. Advanced topics dynamic polymorphism, RAII, template meta programming, static polymorphism, SFINAE, etc. C++11 features smart pointers, lambda expressions, variadic templates, random numbers, chrono library, threads, etc. C++14 features generic lambdas, variable templates C++17 features guaranteed copy elision, structured bindings, fold expressions Upcoming C++20 features modules, concepts, ranges, coroutines The baseline for the lecture is the C++11 standard, with changes due to C++14 and C++17 taken into account. The new features of the upcoming C++20 standard will be introduced where appropriate.
    [Show full text]
  • My Ideas for a Talk
    Introduction We love C++, is it? My ideas for a talk. ... let's visit #random on slack for an idea Michele Caini (skypjack) Idioms Novemeber 30, 2019 1 / 24 Introduction We love C++, is it? Italian C++ Community on Slack Michele Caini (skypjack) Idioms Novemeber 30, 2019 2 / 24 Introduction We love C++, is it? Modern C++: yay or nay? So, to sum up: C++ could not be worse than this. Modern C++ is even worse than the good, old C++98. The Standard Template Library is all wrong, no doubts about it. Containers have some (many?) design problems. The C++ Standards Committee is focusing only on useless things. and so on. Join us on slack and leave your complaint! :) Is it really like this? Let's nd out together. Michele Caini (skypjack) Idioms Novemeber 30, 2019 3 / 24 Introduction We love C++, is it? Idioms You're doing it right Michele Caini skypjack Novemeber 30, 2019 Released under CC BY-SA 4.0 Michele Caini (skypjack) Idioms Novemeber 30, 2019 4 / 24 Idioms You're doing it right C++ has its idioms Programming idioms An idiom is a phrase that doesn't make literal sense, but makes sense once you're acquainted with the culture in which it arose. Programming idioms are no dierent. They are the little things you do daily in a particular programming language or paradigm that only make sense to a person after getting it Courtesy of WikiWikiWeb. Michele Caini (skypjack) Idioms Novemeber 30, 2019 5 / 24 Idioms You're doing it right Good old one: erase-remove Intent To eliminate elements from a container.
    [Show full text]