gcc/testsuite/g++.dg/init/struct2.C
raw| 1 | /* PR c++/23180. */ |
| 2 | /* Initialize a local structure with an expression that attempts to use |
| 3 | pointer arithmetic to calculate another structure field offset. */ |
| 4 | |
| 5 | void saveLoadEntries(const void *); |
| 6 | |
| 7 | void saveOrLoad() { |
| 8 | struct Track { |
| 9 | char soundName[15]; |
| 10 | }; |
| 11 | struct SaveLoadEntry { |
| 12 | int offs; |
| 13 | int type; |
| 14 | int size; |
| 15 | }; |
| 16 | |
| 17 | SaveLoadEntry trackEntries = { |
| 18 | ((int) (__SIZE_TYPE__) (&((Track *) 42)->soundName[0])) - 42, |
| 19 | 0, 1 |
| 20 | }; |
| 21 | saveLoadEntries(&trackEntries); |
| 22 | } |