Changes between Initial Version and Version 1 of Ticket #8037, comment 6


Ignore:
Timestamp:
Sep 21, 2013 5:11:06 AM (23 months ago)
Author:
monoidal
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #8037, comment 6

    initial v1  
    1 Great, I can now reproduce. I looked into internals of OpenGL and OpenGLRaw and here's a version which does not have the dependency. Compile with -O to get the panic, both 7.6 and HEAD.
     1Great, I can now reproduce. I looked into internals of OpenGL and OpenGLRaw and here's a version which does not have the dependency. Compile with -O to get the panic, both 7.6 and HEAD. (edit: made it smaller)
    22
    33{{{
     
    55
    66import Unsafe.Coerce
    7 import Foreign.Ptr
    87import Foreign.C.Types
    98import System.IO.Unsafe
    109
    11 data D4 = D4 Double Double Double Double
     10data D4 = D4 CInt CInt CInt
     11data Color3 = Color3 CInt CInt
    1212
    1313crash :: D4 -> IO ()
    14 crash c = color (invalidCast c)
     14crash = color . unsafeCoerce
    1515
    16 invalidCast :: D4 -> Color3 CDouble
    17 invalidCast = unsafeCoerce
     16color :: Color3 -> IO ()
     17color (Color3 r g) = f (unsafePerformIO undefined) r g
    1818
    19 class Color a where
    20    color  :: a -> IO ()
    21    colorv :: [a] -> IO ()
    22 
    23 data Color3 a = Color3 !a !a !a
    24 
    25 instance ColorComponent a => Color (Color3 a) where
    26    color (Color3 r g b) = color3 r g b
    27 
    28 class ColorComponent a where
    29    color3 :: a -> a -> a -> IO ()
    30 
    31 instance ColorComponent CDouble where
    32    color3 = g
    33 
    34 type Invoker a = FunPtr a -> a
    35 
    36 foreign import ccall dyn_g :: Invoker (CDouble -> CDouble -> CDouble -> IO ())
    37 g :: CDouble -> CDouble -> CDouble -> IO ()
    38 g = dyn_g ptr_g
    39 ptr_g :: FunPtr a
    40 ptr_g = unsafePerformIO undefined
     19foreign import ccall f :: CInt -> CInt -> CInt -> IO ()
    4120}}}