@@ -173,6 +173,32 @@ $(H2 $(LNAME2 extensions, Extensions))
173
173
174
174
$(H2 $(LNAME2 gnu-clang-extensions, Gnu and Clang Extensions))
175
175
176
+ $(P `gcc` and `clang` are presumed to have the same behavior w.r.t. extensions,
177
+ so `gcc` as used here refers to both.)
178
+
179
+ $(H3 $(LNAME2 noreturn, `__attribute__((noreturn))`))
180
+
181
+ $(P `__attribute__((noreturn))` marks a function as never returning.
182
+ `gcc` set this as an attribute of the function, it is
183
+ not part of the function's type. In D, a function that never returns
184
+ has the return type `noreturn`. The difference can be seen with the
185
+ code:)
186
+ ---
187
+ attribute((noreturn)) int foo();
188
+ size_t x = sizeof(foo());
189
+ ---
190
+ $(P This code is accepted by `gcc`, but makes no sense for D. Hence,
191
+ although it works in ImportC, it is not representable as D code,
192
+ meaning one must use judgement in creating a .di file to interface
193
+ with C `noreturn` functions.)
194
+
195
+ $(P Furthermore, the D compiler takes advantage of `noreturn` functions
196
+ by issuing compile time errors for unreachable code. Such unreachable
197
+ code, however, is valid C11, and the ImportC compiler will accept it.)
198
+
199
+ $(BEST_PRACTICE C code that uses the `noreturn` attribute should at the
200
+ very least set the return type to `void`.)
201
+
176
202
177
203
$(H2 $(LNAME2 visualc-extensions, Visual C Extensions))
178
204
0 commit comments