Skip to content
Snippets Groups Projects
  • Richard Smith's avatar
    c1d70e9b
    DR583, DR1512: Implement a rewrite to C++'s 'composite pointer type' rules. · c1d70e9b
    Richard Smith authored
    This has two significant effects:
    
    1) Direct relational comparisons between null pointer constants (0 and nullopt)
       and pointers are now ill-formed. This was always the case for C, and it
       appears that C++ only ever permitted by accident. For instance, cases like
         nullptr < &a
       are now rejected.
    
    2) Comparisons and conditional operators between differently-cv-qualified
       pointer types now work, and produce a composite type that both source
       pointer types can convert to (when possible). For instance, comparison
       between 'int **' and 'const int **' is now valid, and uses an intermediate
       type of 'const int *const *'.
    
    Clang previously supported #2 as an extension.
    
    We do not accept the cases in #1 as an extension. I've tested a fair amount of
    code to check that this doesn't break it, but if it turns out that someone is
    relying on this, we can easily add it back as an extension.
    
    
    git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@284800 91177308-0d34-0410-b5e6-96231b3b80d8
    c1d70e9b
    History
    DR583, DR1512: Implement a rewrite to C++'s 'composite pointer type' rules.
    Richard Smith authored
    This has two significant effects:
    
    1) Direct relational comparisons between null pointer constants (0 and nullopt)
       and pointers are now ill-formed. This was always the case for C, and it
       appears that C++ only ever permitted by accident. For instance, cases like
         nullptr < &a
       are now rejected.
    
    2) Comparisons and conditional operators between differently-cv-qualified
       pointer types now work, and produce a composite type that both source
       pointer types can convert to (when possible). For instance, comparison
       between 'int **' and 'const int **' is now valid, and uses an intermediate
       type of 'const int *const *'.
    
    Clang previously supported #2 as an extension.
    
    We do not accept the cases in #1 as an extension. I've tested a fair amount of
    code to check that this doesn't break it, but if it turns out that someone is
    relying on this, we can easily add it back as an extension.
    
    
    git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@284800 91177308-0d34-0410-b5e6-96231b3b80d8
Code owners
Assign users and groups as approvers for specific file changes. Learn more.