main(){} definiert keinen Prototyp
nach
- N2176 6.7.6 Declarators
- Syntax
- 1 declarator:
- ...
- direct-declarator ( parameter-type-list )
- direct-declarator ( identifier-listopt )
hat der Deklarator einer Funktion in einer Funktionsdefinition eine der beiden angegebenen Formen. Weiter heißt es:
- N2176 6.7.6 Declarators p14
- An identifier list declares only the identifiers of the parameters of the function. An empty list in a function declarator that is part of a definition of that function specifies that the function has no parameters.
Nur bei Verwendung der zweiten Form können die Klammern leer sein! Diese definiert aber keinen Prototyp, da sie laut obigem Zitat nur Name deklariert. Das folgende Zitat sagt, wann ein Prototyp deklariert wird: Nur bei Verwendung einer parameter-type-list, die ja nicht leer sein darf!
- 6.9.1 Function definitions, p7
- If the declarator includes a parameter type list, the list also specifies the types of all the parameters; such a declarator also serves as a function prototype for later calls to the same function in the same translation unit.
- 6.2.1 Scopes of identifiers p2
- 2 ... (A function prototype is a declaration of a function that declares the types of its parameters.)
Anmerkung: Die Bedeutung eines Prototyps wird von dem folgenden Zitat gegeben.
- 6.7.6.3 Function declarators (including prototypes), p14
- If one type has a parameter type list and the other type is specified by a function definition that contains a (possibly empty) identifier list, both shall agree in the number of parameters, and the type of each prototype parameter shall be compatible with the type that results from the application of the default argument promotions to the type of the corresponding identifier.
Überlauf ist UB
- Zitat
- “If an exceptional condition occurs during the evaluation of an expression (that is, if the result is not mathematically defined or not in the range of representable values for its type), the behavior is undefined.”
- N2176 6.5p5
Vorzeichenlose Werte sind in Restklassenring
- Zitat
- “The range of nonnegative values of a signed integer type is a subrange of the corresponding unsigned integer type, and the representation of the same value in each type is the same. A computation involving unsigned operands can never overflow, because a result that cannot be represented by the resulting unsigned integer type is reduced modulo the number that is one greater than the largest value that can be represented by the resulting type.”
- N2176 6.2.5p9
Jede Definition ist eine Deklaration
- Zitat
- “A definition of an identifier is a declaration for that identifier that:
— for an object, causes storage to be reserved for that object;
— for a function, includes the function body;121)
— for an enumeration constant, is the (only) declaration of the identifier;
— for a typedef name, is the first (or only) declaration of the identifier.” - N2176 6.7p5
Ein Gleitkommanumeral hat den Typ »double«
- Zitat
- “An unsuffixed floating constant has type double.”
- N1570 6.4.4.2p4:
Nichtsequenzierte Zugriffe sind UB
- N1570.txt, 6.5p2s1
- “If a side effect on a scalar object is unsequenced relative to either a different side effect on the same scalar object or a value computation using the value of the same scalar object, the behavior is undefined.”
Die letzte Zeile eines Textstroms sollte terminiert werden
- M1570? 7.19.2p2
- "A text stream is an ordered sequence of characters composed into lines, each line consisting of zero or more characters plus a terminating new-line character. Whether the last line requires a terminating new-line character is implementation-defined. ..."