[PATCH] D129872: [clang][OpenMP] Fix runtime crash in the call to __kmp_alloc.

Alexey Bataev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 22 11:00:16 PDT 2022


ABataev added a comment.

In D129872#3672332 <https://reviews.llvm.org/D129872#3672332>, @jyu2 wrote:

> In D129872#3671847 <https://reviews.llvm.org/D129872#3671847>, @ABataev wrote:
>
>> Why does it get truncated if the type must be integer? Probably, something incorrect in sema.
>
> This is only failed with C.  But not for C++.  So I don't think we have problem for Seam.  I may missing something...
> The different is in reprehensive of enum type between c vs c++:
> For C:
>
> | -EnumDecl 0x1193f838 <line:18:9, line:33:1> line:18:14 omp_allocator_handle_t |
> |                                                                               | -EnumConstantDecl 0x1193f940 <line:19:3, col:24> col:3 referenced omp_null_allocator 'int'    |
> |                                                                               | `-ConstantExpr 0x1193f920 <col:24> 'int'                                                      |
> |                                                                               |                                                                                               | -value: Int 0 |
> |                                                                               | `-IntegerLiteral 0x1193f900 <col:24> 'int' 0                                                  |
> |                                                                               | -EnumConstantDecl 0x1193f9d0 <line:20:7, col:31> col:7 referenced omp_default_mem_alloc 'int' |
> |                                                                               | `-ConstantExpr 0x1193f9b0 <col:31> 'int'                                                      |
> |                                                                               |                                                                                               | -value: Int 1 |
> |                                                                               | `-IntegerLiteral 0x1193f990 <col:31> 'int' 1                                                  |
> |
>
> for C++:
>
> | -EnumDecl 0x11b31d88 <line:18:9, line:33:1> line:18:14 omp_allocator_handle_t |
> |                                                                               | -EnumConstantDecl 0x11b31e90 <line:19:3, col:24> col:3 referenced omp_null_allocator 'omp_allocator_handle_t'    |
> |                                                                               | `-ImplicitCastExpr 0x11b4b770 <col:24> 'unsigned long' <IntegralCast>                                            |
> |                                                                               | `-ConstantExpr 0x11b31e70 <col:24> 'int'                                                                         |
> |                                                                               |                                                                                                                  | -value: Int 0 |
> |                                                                               | `-IntegerLiteral 0x11b31e50 <col:24> 'int' 0                                                                     |
> |                                                                               | -EnumConstantDecl 0x11b31f20 <line:20:7, col:31> col:7 referenced omp_default_mem_alloc 'omp_allocator_handle_t' |
> |                                                                               | `-ImplicitCastExpr 0x11b4b788 <col:31> 'unsigned long' <IntegralCast>                                            |
> |                                                                               | `-ConstantExpr 0x11b31f00 <col:31> 'int'                                                                         |
> |                                                                               |                                                                                                                  | -value: Int 1 |
> |                                                                               | `-IntegerLiteral 0x11b31ee0 <col:31> 'int' 1                                                                     |
> |

If the type does not match, we have a problem with casting. Need to add an explicit cast to int-like type rather than avoid implicit casts.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129872/new/

https://reviews.llvm.org/D129872



More information about the cfe-commits mailing list