Ok, I did more testing, tweaking and abracadabring and I think I finally found where the problem is (but I'm not sure why it is).
As you, Elias, said the problem is the "makecolor" family. If I do this:
al_draw_line (a, b, c, d, al_map_rgb_f (1, 1, 1), 1);
it fails, but if I do this:
ColorWhite := al_map_rgb_f (1, 1, 1);
al_draw_line (a, b, c, d, ColorWhite, 1);
then it works.
I suspect the problem is that Free Pascal enables CPU exceptions for data conversion or the optimizations that you said, or both.
Now, I'll try a to find a workaround, but I've found that font drawing still raises a "Runtime error 217..." at exit. But it draws the text correctly using the workaround above.