Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,262
    • Issues 4,262
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 419
    • Merge Requests 419
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #16810

Closed
Open
Opened Jun 13, 2019 by kazu-yamamoto@trac-kazu-yamamoto

Use explicit lazy binding around undefined in inlinable functions

Summary

undefined in inlinable functions are unintentionally evaluated if called strictly. An example:

{-# INLINE alloca #-}
alloca :: forall a b . Storable a => (Ptr a -> IO b) -> IO b
alloca  =
  allocaBytesAligned (sizeOf (undefined :: a)) (alignment (undefined :: a))

Steps to reproduce

Use Foreign.Marshal.Alloc.alloca with Strict language extension.

Expected behavior

It should allocate a memory, not evaluating undefined. If undefineds are used in inlinable functions, lazy bindings must be used explicitly for GHC 8.0 or later.

Environment

  • GHC version used: 8.0 or later

Optional:

Edited Jun 13, 2019 by kazu-yamamoto
Assignee
Assign to
8.9
Milestone
8.9
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#16810