Skip to content

GHC should be able to warn on unsafe CPP usage

GCC has a warning -Wundef that catches unsafe CPP usage like:

#if variable_does_not_exist
// something
#endif

The GCC man page says about -Wundef:

  -Wundef
    Warn if an undefined identifier is evaluated in an "#if" directive.

Following GCC's lead, GHC should have a similar warning flag to detect and warn about this problem in Haskell code that uses CPP.

Trac metadata
Trac field Value
Version 8.1
Type FeatureRequest
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
Edited by erikd
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information