forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitd1211c6
committed
Add macro to cast away const without allowing changes to underlying type.
The new unconsitify(underlying_type, var) macro allows to castconstness away from a variable, but doesn't allow changing theunderlying type. Enforcement of the latter currently only works forgcc like compilers.Please note IT IS NOT SAFE to cast constness away if the variable will everbe modified (it would be undefined behaviour). Doing so anyway can causecompiler misoptimizations or runtime crashes (modifying readonly memory).It is only safe to use when the the variable will not be modified, but APIdesign or language restrictions prevent you from declaring that(e.g. because a function returns both const and non-const variables).This'll be used in an upcoming change, but seems like it's independentinfrastructure.Author: Andres FreundDiscussion:https://postgr.es/m/20181015200754.7y7zfuzsoux2c4ya@alap3.anarazel.de1 parent2c300c6 commitd1211c6
1 file changed
+24
-0
lines changedLines changed: 24 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1121 | 1121 |
| |
1122 | 1122 |
| |
1123 | 1123 |
| |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
1124 | 1148 |
| |
1125 | 1149 |
| |
1126 | 1150 |
| |
|
0 commit comments
Comments
(0)