|
1 | 1 | Version 7.1 |
2 | 2 |
|
| 3 | +11/10/26 [GH #501] |
| 4 | +Array new with a wide string literal initializer in constant evaluation |
| 5 | + |
| 6 | +During constant evaluation, the initializer of an array new-expression that is |
| 7 | +a string literal of a character type wider than one byte (e.g., wchar_t) was |
| 8 | +treated as having as many elements as the literal has bytes, so a large enough |
| 9 | +array could be diagnosed as too small for it. For example: |
| 10 | + |
| 11 | + constexpr int f(int n) { |
| 12 | + auto p = new wchar_t[n]{L"ab"}; |
| 13 | + int r = p[1]; |
| 14 | + delete[] p; |
| 15 | + return r; |
| 16 | + } |
| 17 | + static_assert(f(3) == L'b'); // Previously an error; now okay. |
| 18 | + |
| 19 | + |
| 20 | +11/10/26 [GH #252] |
| 21 | +C-generating back end: inline-only definitions emitted as external ones |
| 22 | + |
| 23 | +When an inline function definition was to be used only for inlining (for |
| 24 | +example, a member of a class template specialization that is the subject of |
| 25 | +an explicit instantiation declaration), the C-generating back end emitted it |
| 26 | +as an "extern __inline__" definition for GCC and Clang. That form is a |
| 27 | +definition only for inlining under the GNU C89 rules, but an external |
| 28 | +definition under the C99 rules that GCC uses by default since version 5. |
| 29 | +Every object file that used such a function then contained an external |
| 30 | +definition of it, and linking two such object files failed. For example, |
| 31 | +with --c++17: |
| 32 | + |
| 33 | + // a.h |
| 34 | + template <class T> struct A { |
| 35 | + int f() { return 1; } |
| 36 | + }; |
| 37 | + extern template struct A<int>; |
| 38 | + |
| 39 | + // a.cpp |
| 40 | + #include "a.h" |
| 41 | + int g1() { return A<int>().f(); } |
| 42 | + |
| 43 | + // b.cpp |
| 44 | + #include "a.h" |
| 45 | + int g2() { return A<int>().f(); } // Linking with a.cpp previously failed. |
| 46 | + |
| 47 | + // c.cpp |
| 48 | + #include "a.h" |
| 49 | + template struct A<int>; |
| 50 | + |
| 51 | +The same problem affected GNU C89 "extern inline" functions, functions with |
| 52 | +the gnu_inline attribute in C99 and later C modes (which lost the "extern" |
| 53 | +keyword), and such definitions of functions with an ellipsis (which were not |
| 54 | +marked inline). This is now fixed: The C-generating back end now adds the |
| 55 | +__gnu_inline__ attribute to "extern __inline__" definitions, keeps "extern" |
| 56 | +for functions with the gnu_inline attribute, and marks a definition only for |
| 57 | +inlining as inline even when the function has an ellipsis. |
| 58 | + |
| 59 | + |
| 60 | +11/10/26 [GH #470] |
| 61 | +GNU, Clang, and Microsoft compatibility: Init-captures in lambda headers |
| 62 | + |
| 63 | +P2579 (adopted as a defect report) makes init-captures visible throughout a |
| 64 | +lambda header, and the front end implemented that in all modes. However, GCC |
| 65 | +before version 16, Clang before version 17, and MSVC before version 19.50 (or |
| 66 | +in pre-C++20 modes) make init-captures visible only in the lambda body: In |
| 67 | +the lambda header (e.g., in a parameter type, an exception specification, or |
| 68 | +a trailing return type), the name of an init-capture refers to an entity of |
| 69 | +the enclosing scope instead. (In pre-C++20 modes, MSVC does make |
| 70 | +init-captures visible in the exception specification and trailing return type |
| 71 | +of a generic lambda.) The front end now emulates that in the corresponding |
| 72 | +modes. For example, with --g++ --gnu_version=130300 --c++14: |
| 73 | + |
| 74 | + struct X { int value; }; |
| 75 | + void f() { |
| 76 | + X x = {2}; |
| 77 | + auto lm = [x = 10]() -> decltype(x) { return {}; }; |
| 78 | + // Previously the return type was int. Now it is X. |
| 79 | + } |
| 80 | + |
| 81 | + |
3 | 82 | 11/9/26 [GH #90] |
4 | 83 | Constexpr reads of zero-initialized members after value initialization |
5 | 84 |
|
|
0 commit comments