This bugzilla service is closed. All entries have been migrated to

Bug 1369

Summary: silence compiler warnings due to type mismatch (GeneralMatrixMatrix.h, Parallelizer.h)
Product: Eigen Reporter: Jeff Hammond <>
Component: Core - matrix productsAssignee: Nobody <eigen.nobody>
Severity: Unknown CC: chtz, gael.guennebaud,
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: All   
Bug Depends on:    
Bug Blocks: 558    
Description Flags
Git patch file none

Description Jeff Hammond 2016-12-27 23:35:38 UTC
I apologize for this, but I have not yet reminded myself how to use Mercurial.  I have a trivial (four line) patch against the Github mirror, which anyone can reproduce in seconds.

See or below (from git format-patch 50015ab88ef680617747a3c25e956064b07430a9 && cat 0001-silence-compiler-warnings-due-to-type-mismatch.patch) for details.

From 1f9f77b1dfa3a74ad81ac2b649a3740ac35ec1b2 Mon Sep 17 00:00:00 2001
From: Jeff Hammond <>
Date: Wed, 21 Dec 2016 21:51:17 -0800
Subject: [PATCH] silence compiler warnings due to type mismatch

1) omp thread ids are always int, so the return values of
   the associated runtime functions should be stored in
   int values, not Index values.

2) because sync and users are compared or stored to from Index,
   they need to be Index, not int, because Index can (and is in my case)
   a ptrdiff_t, which is a 64b type (when int is a 32b type).

It is not clear why Index is not an int, but presumably Eigen supports
matrices of rank greater than INT_MAX.

The use of volatile qualifier on sync suggests unsafe assumptions about
how inter-thread synchronization works, but that is a problem for
another day.
 Eigen/src/Core/products/GeneralMatrixMatrix.h | 4 ++--
 Eigen/src/Core/products/Parallelizer.h        | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/Eigen/src/Core/products/GeneralMatrixMatrix.h b/Eigen/src/Core/products/GeneralMatrixMatrix.h
index 61df3be57..75e56ea22 100644
--- a/Eigen/src/Core/products/GeneralMatrixMatrix.h
+++ b/Eigen/src/Core/products/GeneralMatrixMatrix.h
@@ -83,8 +83,8 @@ static void run(Index rows, Index cols, Index depth,
     // this is the parallel version!
-    Index tid = omp_get_thread_num();
-    Index threads = omp_get_num_threads();
+    int tid = omp_get_thread_num();
+    int threads = omp_get_num_threads();
     LhsScalar* blockA = blocking.blockA();
diff --git a/Eigen/src/Core/products/Parallelizer.h b/Eigen/src/Core/products/Parallelizer.h
index 2a31e4cbe..4b4ca669a 100644
--- a/Eigen/src/Core/products/Parallelizer.h
+++ b/Eigen/src/Core/products/Parallelizer.h
@@ -75,8 +75,8 @@ template<typename Index> struct GemmParallelInfo
   GemmParallelInfo() : sync(-1), users(0), lhs_start(0), lhs_length(0) {}
-  int volatile sync;
-  int volatile users;
+  Index volatile sync;
+  Index volatile users;
   Index lhs_start;
   Index lhs_length;
Comment 1 Jeff Hammond 2016-12-27 23:36:27 UTC
Created attachment 764 [details]
Git patch file
Comment 2 Gael Guennebaud 2016-12-28 22:38:00 UTC
Thanks for the patch, I applied slightly fixes though:

I'll wait a bit before backporting them and closing this entry.
Comment 4 Nobody 2019-12-04 16:40:59 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: