digitalmars.D - Porting GDC to QNX
- Sheff (13/13) Apr 23 2007 Hi!
Hi! I'm porting GDC compiler to QNX (my previous posts related to this topic are: http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmar .D&article_id=51281 and http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=51456) I'm almost done here, everything is working great, except one little thing: optimization. It seems to me that -O1, -O2 and -O3 (but not -Os) options generate bad code. The problem is that the following code doesn't work as expected: char a = "abcd"; char r; r = a.dup.reverse; assert(r == "dcba"); a = "a\u1235\u1234c"; r = a.dup.reverse; assert(r == "c\u1234\u1235a"); When you compile it without optimization everything is ok, but when you use -O for example, the following happens: function _adReverseChar (that's the function that is called when you use .reverse) works for a very very very long time, that happens because the "char a" parameter that is passed to that function is passed wrongly, if you call a.length then you'll see that it'll return something like 134_XXX_XXX, i.e a very large number though the real size of a string is 4. What could be the problem ? I really don't have a clue, because same code works fine with -O in linux and QNX is a lot like linux. So it's unlikely that gcc optimizer works different in linux and qnx, that means that I probably forgot to turn on/off some switches while compiling GDC, does anyone have any ideas what exactly could it be ?
Apr 23 2007