Files
2025-10-25 03:02:53 +03:00

95 lines
2.6 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[diff.stat]
# Annex C (informative) Compatibility [[diff]](./#diff)
## C.7 C++ and C [[diff.iso]](diff.iso#diff.stat)
### C.7.5 [[stmt]](stmt "8Statements"): statements [diff.stat]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3120)
**Affected subclauses:** [[stmt.switch]](stmt.switch) and [[stmt.goto]](stmt.goto)
**Change:** It is now invalid to jump past a declaration with explicit or implicit initializer (except across entire block not entered)[.](#1.sentence-1)
**Rationale:** Constructors used in initializers may allocate
resources which need to be de-allocated upon leaving the
block[.](#1.sentence-2)
Allowing jump past initializers would require
complicated runtime determination of allocation[.](#1.sentence-3)
Furthermore, many operations on such an uninitialized object
have undefined behavior[.](#1.sentence-4)
With this simple compile-time rule, C++ assures that
if an initialized variable is in scope, then it has assuredly been
initialized[.](#1.sentence-5)
**Effect on original feature:** Deletion of semantically well-defined feature[.](#1.sentence-6)
**Difficulty of converting:** Semantic transformation[.](#1.sentence-7)
**How widely used:** Seldom[.](#1.sentence-8)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/compatibility.tex#L3141)
**Affected subclause:** [[stmt.return]](stmt.return)
**Change:** It is now invalid to return (explicitly or implicitly) from a function which is
declared to return a value without actually returning a value[.](#2.sentence-1)
**Rationale:** The caller and callee may assume fairly elaborate
return-value mechanisms for the return of class objects[.](#2.sentence-2)
If
some flow paths execute a return without specifying any value,
the implementation must embody many more complications[.](#2.sentence-3)
Besides,
promising to return a value of a given type, and then not returning
such a value, has always been recognized to be a questionable
practice, tolerated only because very-old C had no distinction between
functions with void and int return types[.](#2.sentence-4)
**Effect on original feature:** Deletion of semantically well-defined feature[.](#2.sentence-5)
**Difficulty of converting:** Semantic transformation[.](#2.sentence-6)
Add an appropriate return value to the source code, such as zero[.](#2.sentence-7)
**How widely used:** Seldom[.](#2.sentence-8)
For several years, many existing C implementations have produced warnings in
this case[.](#2.sentence-9)