Affected subclauses: [stmt.switch] and
[stmt.goto]
Change:
It is now invalid to jump past a declaration with explicit or implicit initializer (except across entire block not entered)
. Rationale:
Constructors used in initializers may allocate
resources which need to be de-allocated upon leaving the
block
. Allowing jump past initializers would require
complicated runtime determination of allocation
. Furthermore, any use of the uninitialized object could be a
disaster
. With this simple compile-time rule, C++ assures that
if an initialized variable is in scope, then it has assuredly been
initialized
. Effect on original feature:
Deletion of semantically well-defined feature
. Difficulty of converting:
Semantic transformation
. Affected subclause: [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
. Rationale:
The caller and callee may assume fairly elaborate
return-value mechanisms for the return of class objects
. If
some flow paths execute a return without specifying any value,
the implementation must embody many more complications
. 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
void functions and int functions
. Effect on original feature:
Deletion of semantically well-defined feature
. Difficulty of converting:
Semantic transformation
. Add an appropriate return value to the source code, such as zero
. For several years, many existing C implementations have produced warnings in
this case
.