[Openmp-dev] Two warnings with clang 3.5 on ppc63le

Cownie, James H james.h.cownie at intel.com
Mon Mar 2 02:28:27 PST 2015


1.
/home/compteam/slave0/build_folder_omp/libiomp-src/runtime/src/kmp_error.c:124:23: warning: comparison of constant 16 with expression of type 'enum cons_type' is always true [-Wtautological-constant-out-of-range-compare]
    if ( 0 < ct && ct <= cons_text_c_num ) {;
                   ~~ ^  ~~~~~~~~~~~~~~~

It looks like that there are no machines where const char * is more that 64-bit. The second check can be removed safely - maybe the author of this intended something different?

I think you're misunderstanding the point here. cons_text_c_num gives us the number of elements in the table. The point so to ensure that the value we've been passed is a correct index into the table. The compiler is right that *if* the value passed is a correct member of the enumeration it can't be outside the range, but the check is there precisely to ensure that the value passed in is in range (because we can't tell here that someone didn't call this with "(enum cons_type)1000").

So I think what we need here is a cast so that your compiler is happy, rather than removing the test.
Something like
     if ( 0 < ct && ((int)ct) <= cons_text_c_num ) {;

You could write the whole thing as
    if ( ((unsigned int)ct) <= cons_text_c_num ) {;
but that may be a little too clever for its own good, especially since the performance of this code can't matter.

-- Jim

James Cownie <james.h.cownie at intel.com>
SSG/DPD/TCAR (Technical Computing, Analyzers and Runtimes)
Tel: +44 117 9071438

From: openmp-dev-bounces at cs.uiuc.edu [mailto:openmp-dev-bounces at cs.uiuc.edu] On Behalf Of Carlo Bertolli
Sent: Friday, February 27, 2015 10:57 PM
To: openmp-dev at dcs-maillist2.engr.illinois.edu
Subject: [Openmp-dev] Two warnings with clang 3.5 on ppc63le


Hi

Using clang 3.5 on ppc64le, I obtained the following warnings.

1.
/home/compteam/slave0/build_folder_omp/libiomp-src/runtime/src/kmp_error.c:124:23: warning: comparison of constant 16 with expression of type 'enum cons_type' is always true [-Wtautological-constant-out-of-range-compare]
    if ( 0 < ct && ct <= cons_text_c_num ) {;
                   ~~ ^  ~~~~~~~~~~~~~~~

It looks like that there are no machines where const char * is more that 64-bit. The second check can be removed safely - maybe the author of this intended something different?

2.
/home/compteam/slave0/build_folder_omp/libiomp-src/runtime/src/kmp_runtime.c:270:58: warning: multiple unsequenced modifications to 'gtid' [-Wunsequenced]
    if ( __kmp_env_checks == TRUE && !KMP_UBER_GTID(gtid = __kmp_gtid_from_thread( th )))
                                                         ^
/home/compteam/slave0/build_folder_omp/libiomp-src/runtime/src/kmp.h:958:25: note: expanded from macro 'KMP_UBER_GTID'
        (__kmp_threads[(gtid)] == __kmp_root[(gtid)]->r.r_uber_thread)\
                        ^

gtid here is modified multiple times. We can just move the assignment out of the if and have only gtid as parameter of the macro.


Below a patch that fixes these problems. Please let me know your thoughts on this.

Thanks

-- Carlo




diff --git a/runtime/src/kmp_error.c b/runtime/src/kmp_error.c
index b76c109..4274365 100644
--- a/runtime/src/kmp_error.c
+++ b/runtime/src/kmp_error.c
@@ -121,7 +121,7 @@ __kmp_pragma(
     kmp_str_buf_t buffer;
     kmp_msg_t     prgm;
     __kmp_str_buf_init( & buffer );
-    if ( 0 < ct && ct <= cons_text_c_num ) {;
+    if ( 0 < ct ) {
         cons = cons_text_c[ ct ];
     } else {
         KMP_DEBUG_ASSERT( 0 );
diff --git a/runtime/src/kmp_runtime.c b/runtime/src/kmp_runtime.c
index 55b58ce..0a08993 100644
--- a/runtime/src/kmp_runtime.c
+++ b/runtime/src/kmp_runtime.c
@@ -267,7 +267,8 @@ __kmp_check_stack_overlap( kmp_info_t *th )
     }

     /* No point in checking ubermaster threads since they use refinement and cannot overlap */
-    if ( __kmp_env_checks == TRUE && !KMP_UBER_GTID(gtid = __kmp_gtid_from_thread( th )))
+    gtid = __kmp_gtid_from_thread( th );
+    if ( __kmp_env_checks == TRUE && !KMP_UBER_GTID(gtid))
     {
         KA_TRACE(10,("__kmp_check_stack_overlap: performing extensive checking\n"));
         if ( stack_beg == NULL ) {
---------------------------------------------------------------------
Intel Corporation (UK) Limited
Registered No. 1134945 (England)
Registered Office: Pipers Way, Swindon SN3 1RJ
VAT No: 860 2173 47

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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/openmp-dev/attachments/20150302/eced25c1/attachment.html>


More information about the Openmp-dev mailing list