[MOAB-dev] ParallelComm.cpp - potential bug
Robert Maynard
robert.maynard at kitware.com
Wed Dec 5 10:13:44 CST 2012
-Wshadow can be used with GCC or clang to produce these exact warnings.
I prefer to setup test builds with the following compiler flags to find as
many possible errors: -Wall -Wextra -Wcast-align -Wpointer-arith -Wformat
-Wformat-security -Wshadow -Wunused-parameter
On Tue, Dec 4, 2012 at 7:42 PM, Vijay S. Mahadevan <vijay.m at gmail.com>wrote:
> I pulled the latest moab source and compiled with Intel on a linux machine.
>
> I get the following warning which could be serious:
>
> ParallelComm.cpp(4091): remark #1599: declaration hides variable "k"
> (declared at line 4068)
>
> variable k is defined at both 4068 and 4091. I would've modified the
> inner loop to use a different variable but am not sure how to modify
> the source inside correspondingly. Can someone please fix this since
> it could cause some serious bugs because the variable 'k' is ambiguous
> in lines 4094:4098. Using some descriptive variable names for indexes
> would also be helpful rather than i, j, k etc..
>
> 4068 for (int k=0; k<nbPairsMultiShared; k++)
> 4069 {
> 4070 int startMulti=multiSharedStartEnd[2*k];
> 4071 int endMulti =multiSharedStartEnd[2*k+1];
> 4072 // so tuples indices start, end, will be remote sent for multi
> sharing
> 4073 // first tuple sent will be with the owner infos, the other
> 4074 for (int j=startMulti; j<=endMulti; j++)
> 4075 {
> 4076 // first send to processor the info about the local handle
> (which will be the owner)
> 4077 int proc_to_send_to = remoting_entities.vi_wr[j];
> 4078 EntityHandle handle_on_owning_proc =
> remoting_entities.vul_wr[2*j+1]; // it was remote before
> ...................
> ...................
> 4089 multishared_verts.inc_n();
> 4090 // create more tuples, for each instance
> 4091 for (int k=startMulti; k<=endMulti; k++)
> 4092 {
> 4093 multishared_verts.vi_wr[2*indexInTuple] =
> proc_to_send_to; // send to
> 4094 multishared_verts.vi_wr[2*indexInTuple+1] =
> remoting_entities.vi_wr[k]; // multi proc
> 4095 multishared_verts.vl_wr[indexInTuple] =
> remoting_entities.vl_wr[k]; // gid, for debug
> 4096 multishared_verts.vul_wr[2*indexInTuple] =
> handle_with_multi; // remote handle on proc_to_send_to
> 4097 multishared_verts.vul_wr[2*indexInTuple+1] =
> remoting_entities.vul_wr[2*k]; // handle on multi proc
> 4098 indexInTuple++;
> 4099 multishared_verts.inc_n();
> 4100 }
> 4101 }
> 4102 }
>
> Vijay
>
--
Robert Maynard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/moab-dev/attachments/20121205/4ad25806/attachment.html>
More information about the moab-dev
mailing list