First things first, I'm able to run your program without `--opt:size` after some minor modifications.
You're building a `wxListItem` incorrectly since you specify too few masks and the width and format you specify are ignored: see [here](https://github.com/wxWidgets/wxWidgets/blob/cc931612eec2e3ea49200ebff45042135f3c3f9c/src/common/listctrlcmn.cpp#L148,L167) for more info. Now, back to your problem. Specifying `--opt:size` means the compiler (`gcc` in your case) is invoked with `-Os` so it's very likely that the compiler is misoptimizing some code somewhere. What's your `gcc` and `wxWidgets` version? You can always try to update both to the latest version and try again. Regarding your second question, you're getting an error because the `cnew` expression gives you a `ptr WxColour` but `styleSetForeground` needs a `WxColour`. You just have to use the deference operator `c1[]` to get the `WxColor` it points to.
