Difference between revisions of "glossary"
(+copy of two talk posts) |
(+) |
||
Line 1: | Line 1: | ||
{{title|Glossary}} | {{title|Glossary}} | ||
− | This page describes several concepts that will be frequently used in subsequent pages. | + | This page describes several concepts that will be frequently used in subsequent pages. You don't need to learn all of them just yet -- leave this for when you encounter them in other articles. |
+ | |||
+ | ; Compiler | ||
+ | |||
+ | A program that takes textual representation of code and produces a program file that contains machine instructions for a particular processor. | ||
; Undefined behavior | ; Undefined behavior | ||
− | + | Undefined behavior happens when you break certain rules of C++ in your code. It means that the compiler is allowed to do ''anything'' with your code. For example, the compiler may: | |
+ | |||
+ | * refuse to compile code and return an error message instead. | ||
+ | |||
+ | * compile the code successfully, but the program crashes when run. | ||
+ | |||
+ | * compile the code successfully, but the program produces wrong results when run. | ||
+ | |||
+ | * compile the code successfully, but the program works on one computer, but crashes on another. | ||
+ | |||
+ | * [[:enwiki:Undefined_behavior#Compiler_easter_eggs|launch a game]]. | ||
+ | |||
+ | * [http://www.catb.org/jargon/html/N/nasal-demons.html try to make demons to fly out of your nose]. | ||
+ | |||
+ | * etc. | ||
+ | |||
+ | In short, the results of the compilation are unpredictable. A program may appear to run well, but as far as C++ compiler is concerned, the program is broken and even small changes to the environment it runs in may lead to a program crash or to the program returning incorrect results. Thus undefined behavior should be avoided at all costs. | ||
− | + | Undefined behavior is not a silly idea as it might look like. Two of the primary goals of C++ are performance and portability. These aims are contradictory: given the variety of microprocessors in the world, it is almost insurmountable task to design a language that allows code to run well on all of them. C++ solves this issue by simply disallowing certain behaviors of the program. Since the compiler may not be able to detect whether those rules are violated, the C++ language allows it to produce more or less broken programs. Therefore, the programmer must be very careful. | |
− | + | See also [[undefined behariov | extended description and condition list]]. | |
− | + | ; As if rule | |
+ | {{todo}} | ||
− | + | ; One definition rule | |
+ | {{todo}} |
Revision as of 03:16, 4 November 2013
This page describes several concepts that will be frequently used in subsequent pages. You don't need to learn all of them just yet -- leave this for when you encounter them in other articles.
- Compiler
A program that takes textual representation of code and produces a program file that contains machine instructions for a particular processor.
- Undefined behavior
Undefined behavior happens when you break certain rules of C++ in your code. It means that the compiler is allowed to do anything with your code. For example, the compiler may:
- refuse to compile code and return an error message instead.
- compile the code successfully, but the program crashes when run.
- compile the code successfully, but the program produces wrong results when run.
- compile the code successfully, but the program works on one computer, but crashes on another.
- etc.
In short, the results of the compilation are unpredictable. A program may appear to run well, but as far as C++ compiler is concerned, the program is broken and even small changes to the environment it runs in may lead to a program crash or to the program returning incorrect results. Thus undefined behavior should be avoided at all costs.
Undefined behavior is not a silly idea as it might look like. Two of the primary goals of C++ are performance and portability. These aims are contradictory: given the variety of microprocessors in the world, it is almost insurmountable task to design a language that allows code to run well on all of them. C++ solves this issue by simply disallowing certain behaviors of the program. Since the compiler may not be able to detect whether those rules are violated, the C++ language allows it to produce more or less broken programs. Therefore, the programmer must be very careful.
See also extended description and condition list.
- As if rule
This section is incomplete |
- One definition rule
This section is incomplete |