gcc/testsuite/gdc.test/fail_compilation/fail176.d
raw| 1 | /* |
| 2 | TEST_OUTPUT: |
| 3 | --- |
| 4 | fail_compilation/fail176.d(13): Error: cannot modify `immutable` expression `a[1]` |
| 5 | fail_compilation/fail176.d(16): Error: cannot modify `immutable` expression `b[1]` |
| 6 | fail_compilation/fail176.d(19): Error: cannot modify `const` expression `c[1]` |
| 7 | --- |
| 8 | */ |
| 9 | |
| 10 | void foo() |
| 11 | { |
| 12 | auto a = "abc"; |
| 13 | a[1] = 'd'; |
| 14 | |
| 15 | immutable char[3] b = "abc"; |
| 16 | b[1] = 'd'; |
| 17 | |
| 18 | const char[3] c = "abc"; |
| 19 | c[1] = 'd'; |
| 20 | } |