[Openmp-dev] warnings in omp.h from Clang

Churbanov, Andrey via Openmp-dev openmp-dev at lists.llvm.org
Thu Jun 25 11:32:16 PDT 2020


Hi Steve,

You observed expected problem, and I am not sure if it can be solved.  Probably clang could suppress the warnings somehow, though I am not a compiler expert.

The omp_sched_monotonic is the part of OpenMP standard, which does not correspond well with the ISO C here.

The omp_*_handle_t  were intentionally made enumerators with the intention to store pointers there. That's why UINTPRT_MAX used to emphasize the size of the enumerator.
The argument was that the advantage of enumeration versus integer for compilation (allows stricter type checking) overweighs the disadvantage of its non-conformance with the ISO C. Especially given that "all" known compilers support an extension that allows enumerator to be as big as any integer type.

Interestingly gcc does not complain on omp_sched_monotonic by default, but starts complaining if you point to its own include file via -I option (tried gcc version 9.3).

Regards,
Andrey

-----Original Message-----
From: Openmp-dev <openmp-dev-bounces at lists.llvm.org> On Behalf Of Stephen Siegel via Openmp-dev
Sent: Thursday, June 25, 2020 6:37 PM
To: openmp-dev at lists.llvm.org
Subject: [Openmp-dev] warnings in omp.h from Clang

Hello,
I’ve installed Clang 9.0 on my Mac using MacPorts.  When I compile a C/OpenMP program with the flag -pedantic, I get 4 warnings, all of the same kind, in omp.h, e.g. "ISO C restricts enumerator values to range of 'int'  (2147483648 is too large)”.   An example is below.   Do other people get this, or am I doing something wrong?
Thanks,
Steve


basie:diffusion1d siegel$ cat exp.c
#include <omp.h>
int main() {
}

basie:diffusion1d siegel$ clang-mp-9.0 -fopenmp -pedantic exp.c In file included from exp.c:1:
/opt/local/include/libomp/omp.h:53:9: warning: ISO C restricts enumerator values to range of 'int'
      (2147483648 is too large) [-Wpedantic]
        omp_sched_monotonic = 0x80000000
        ^                     ~~~~~~~~~~
/opt/local/include/libomp/omp.h:302:7: warning: ISO C restricts enumerator values to range of 'int'
      (18446744073709551615 is too large) [-Wpedantic]
      KMP_ALLOCATOR_MAX_HANDLE = UINTPTR_MAX
      ^                          ~~~~~~~~~~~
/opt/local/include/libomp/omp.h:315:7: warning: ISO C restricts enumerator values to range of 'int'
      (18446744073709551615 is too large) [-Wpedantic]
      KMP_MEMSPACE_MAX_HANDLE = UINTPTR_MAX
      ^                         ~~~~~~~~~~~
/opt/local/include/libomp/omp.h:343:39: warning: ISO C restricts enumerator values to range of 'int'
      (18446744073709551615 is too large) [-Wpedantic]
    typedef enum omp_event_handle_t { KMP_EVENT_MAX_HANDLE = UINTPTR_MAX } omp_event_handle_t;
                                      ^                      ~~~~~~~~~~~
4 warnings generated.
basie:diffusion1d siegel$ more /opt/local/include/libomp/omp.h
/*
 * include/omp.h.var
 */


//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===//


#ifndef __OMP_H
#   define __OMP_H

#   include <stdlib.h>
#   include <stdint.h>

#   define KMP_VERSION_MAJOR    5
#   define KMP_VERSION_MINOR    0
#   define KMP_VERSION_BUILD    20140926
#   define KMP_BUILD_DATE       "No_Timestamp"

_______________________________________________
Openmp-dev mailing list
Openmp-dev at lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/openmp-dev

--------------------------------------------------------------------
Joint Stock Company Intel A/O
Registered legal address: Krylatsky Hills Business Park,
17 Krylatskaya Str., Bldg 4, Moscow 121614,
Russian Federation

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.


More information about the Openmp-dev mailing list