182 | | 1. Persuade the toy static_map implementation at https://goo.gl/eO7ooa to generate the same minimum output |
183 | | under -O3 optimisation with GCC as it does with clang. Extra bonus points if you can persuade VS2017 to |
184 | | do the same. Super extra bonus points if you get it working with optimisation disabled! You may use C++ 17 |
185 | | features if you find that helps. |
186 | | |
187 | | Submission of the programming test should be via copying and pasting the code you wrote into the end of the proposal you submit to Google Melange. |
| 182 | 1. Study the toy static_map implementation at https://goo.gl/eO7ooa. Note that with optimisation enabled, |
| 183 | clang executes the non-constexpr statement `const char *foo=cmap[5];` entirely as a constant expression |
| 184 | and we get our desired behaviour. '''HOWEVER''' neither GCC nor VS2017 RC1 do so (you can select GCC on godbolt using the dropdown menu). |
| 185 | |
| 186 | 2. Attempt to reimplement the toy static_map implementation so it executes the non-constexpr statement `const char *foo=cmap[5];` |
| 187 | entirely as a constant expression under optimisation on one of GCC or VS2017. |
| 188 | - Note it need not work well with clang. |
| 189 | - You are allowed use C++ 17 only features if that helps you. |
| 190 | - Hints: You will likely see the best success in this task if you completely ignore the toy static_map |
| 191 | we showed you and start again fresh, testing each layer you add to ensure GCC or MSVC is optimising |
| 192 | away your code entirely. Also be aware that MSVC will often do the right thing if you sprinkle forceinline |
| 193 | around, its inliner gives up very early compared to clang or GCC. |
| 194 | |
| 195 | 3. Submission of the programming test should be via copying and pasting the code you wrote into the end of the |
| 196 | proposal you submit to Google. Note that '''we do not expect''' you to succeed in the task, we are |
| 197 | much more interested '''in how you approach the problem''', so please describe step by step how you |
| 198 | approached the problem. |