PGC-S-0058-Illegal lvalue, PGC-W-0095...

hi,

i have a program :
this program was compiled and work with another compiler and another architecture, now i use PGCC and i have some problrme with memory
that how the message that i get
PGC-S-0058-Illegal lvalue (n.c: 394)
and
PGC-S-0058-Illegal lvalue (n.c: 518)
PGC-W-0095-Type cast required for this conversion (n.c: 518)

oh i have a 4 procesor “AMD optheron” 64 bit ant i try
-tp=and64 and i try k8-64
i dont know the reason to this messages

o yeah i can show you how i or they “it’s not my program” declare and use of arrays per haps you this can help you to help me …:-))

In “common.h”

MYVAR Real *ex, *ey, *ez, *hx, *hy, *hz;



In “n.h”

Real 	*PML_ex[6], *PML_ey[6], *PML_ez[6];

In “commen_para.h”


#define HY(i,j,k)            hy[OFF3(i,j,k,nx+2,ny+2,nz+2)]

#define PML_EX(f,i,j,k)   PML_EX(f,OFF3(i,j,k,PML_nbx[f]+2,PML_nby[f]+2,PML_nbz[f]+2))

The first erreur "PGC-S-0058-Ille…"is announced in this line

PML_HY(0,pmld.bk+1,pmld.lt+j,pmld.bt+k)=HY(1,j,k);

and the second " PGC-W-0095"in this

p_ex = & (PML_EX(f,i,j,k));

Any help, or advise will be welcome…

Hi Saad,

Try reviewing the post processed error lines since macros can be difficult to decipher. To do this, add “-P” to your compilation of “n.c”. This instructs the compiler driver to stop after the preprocessing phase and output the results to a “.i” file. Next, compile again substituting “n.i” for “n.c” and remove “-P”.

The same errors should occur, but at different line numbers. However now it should be more evident what the problem is since the code won’t be obfuscated by the macros.

If you are still are having trouble, please post the post processed lines (from the n.i file) where the errors occur as well as the definitions of the left hand variables like “p_ex”.

  • Mat

yes the same ereurs are occured, but it’s just this kind of erreurs.
, i will try -p.

that the the defenition of p_ex:
real …,*p_ex;
do you think that a version of pgcc could be the reason “pgcc 6.0-5 64-bit”?.
thank’s again and i will inform you the result . …:-)

As i prmoise you, and according to your advises, i get a litlle program that have the same problemes


typedef float Real ; 
typedef struct 
{ 
  int bk ; 
  int ft ; 
  int lt ; 
  int rt ; 
  int bt ; 
  int tp ; 
} PML_layer ; 


 

 PML_layer pmld , pmlo ; 


	
Real * PML_hx [ 6 ] , * PML_hy [ 6 ] , * PML_hz [ 6 ] ;
int PML_nbx [ 6 ] , PML_nby [ 6 ] , PML_nbz [ 6 ] ; 
extern Real * ex , * ey , * ez , * hx , * hy , * hz ; 
extern int n , nx , ny , nz ; 



int main ( ) 
{
int i,j,k;
/*#pragma omp for nowait */
	for ( i = 0 ; i <= nx ; i ++ ) 
	  for ( k = 1 ; k <= nz ; k ++ ) { 
	PML_HY ( 0 , ( ( ( pmld . bk + 1 ) * ( PML_nby [ 0 ] + 2 ) + ( pmld . lt + j ) ) * ( PML_nbz [ 0 ] + 2 ) + ( pmld . 

bt + k ) ) ) = hy [ ( ( ( 1 ) * ( ny + 2 ) + ( j ) ) * ( nz + 2 ) + ( k ) ) ] ; 

}
/*#pragma omp for nowait */
	for ( i = 1 ; i <= nx ; i ++ ) 
	  for ( k = 0 ; k <= nz ; k ++ ) { 
	PML_HZ ( 2 , ( ( ( pmld . bk + i ) * ( PML_nby [ 2 ] + 2 ) + ( pmld . lt + 1 ) ) * ( PML_nbz [ 2 ] + 2 ) + ( pmld . 

bt + k ) ) ) = hz [ ( ( ( i ) * ( ny + 2 ) + ( 1 ) ) * ( nz + 2 ) + ( k ) ) ];

}
}

oh i try without extern, and i get the same result …

now i use "pgcc 6.1-6 64-bit target on x86-64 Linux " and this is the erreurs :

PGC-S-0058-Illegal lvalue (test_new.c: 32)
PGC-S-0058-Illegal lvalue (test_new.c: 38)

in the same time i will try by studing this arrays, and by giving them some real variables.
thank’s …, and i an waiting for your advices …:-)

Any advanced dcuments about memory allocation in c , would be welcme as your advice.

Where are “PML_HY” and “PML_HZ” defined? They’re either macros or functions. If they are macros, you need to find their definitions. If they’re functions, then this is illegal code since you can’t assign a value to a function.

  • Mat

i get this code with -P then i theh i think that are not a macros “#define”, i dont know how the program know : it’s not declared "but it’s not important to me because i get no error ", that’s the declaration in *.h file



define OFF2(j,k,J,K)                             ((j)*(K)+(k))
#define OFF3(i,j,k,I,J,K)               (((i)*(J)+(j))*(K)+(k))
#define OFF4(a,i,j,k,A,I,J,K) ((((a)*(I)+(i))*(J)+(j))*(K)+(k))

#define EX(i,j,k)            ex[OFF3(i,j,k,nx+2,ny+2,nz+2)]
#define EY(i,j,k)            ey[OFF3(i,j,k,nx+2,ny+2,nz+2)]
#define EZ(i,j,k)            ez[OFF3(i,j,k,nx+2,ny+2,nz+2)]
#define HX(i,j,k)            hx[OFF3(i,j,k,nx+2,ny+2,nz+2)]
#define HY(i,j,k)            hy[OFF3(i,j,k,nx+2,ny+2,nz+2)]
#define HZ(i,j,k)            hz[OFF3(i,j,k,nx+2,ny+2,nz+2)]

#define EMULT(i,j,k,a)       emult[OFF4(i,j,k,a,nx+2,ny+2,nz+2,6)]
#define HMULT(i,j,k,a)       hmult[OFF4(i,j,k,a,nx+2,ny+2,nz+2,6)]

#define CELL_ARRAY(i,j,k)    cell_array[OFF3(i,j,k,nx+2,ny+2,nz+2)]
#define TYPE_ARRAY(i,j,k)    type_array[OFF3(i,j,k,nx+2,ny+2,nz+2)]

#define SOURCE_ADD(i,j)      source_add[OFF2(i,j,n_source+1,n_step+1)]


#define PML_EX(f,i,j,k)   PML_EX(f,OFF3(i,j,k,PML_nbx[f]+2,PML_nby[f]+2,PML_nbz[f]+2))
#define PML_EY(f,i,j,k)   PML_EY(f,OFF3(i,j,k,PML_nbx[f]+2,PML_nby[f]+2,PML_nbz[f]+2))
#define PML_EZ(f,i,j,k)   PML_EZ(f,OFF3(i,j,k,PML_nbx[f]+2,PML_nby[f]+2,PML_nbz[f]+2))
#define PML_DEX(f,i,j,k)  PML_DEX(f,OFF3(i,j,k,PML_nbx[f]+2,PML_nby[f]+2,PML_nbz[f]+2))
#define PML_DEY(f,i,j,k)  PML_DEY(f,OFF3(i,j,k,PML_nbx[f]+2,PML_nby[f]+2,PML_nbz[f]+2))
#define PML_DEZ(f,i,j,k)  PML_DEZ(f,OFF3(i,j,k,PML_nbx[f]+2,PML_nby[f]+2,PML_nbz[f]+2))
#define PML_PEX(f,i,j,k)  PML_PEX(f,OFF3(i,j,k,PML_nbx[f]+2,PML_nby[f]+2,PML_nbz[f]+2))
#define PML_PEY(f,i,j,k)  PML_PEY(f,OFF3(i,j,k,PML_nbx[f]+2,PML_nby[f]+2,PML_nbz[f]+2))
#define PML_PEZ(f,i,j,k)  PML_PEZ(f,OFF3(i,j,k,PML_nbx[f]+2,PML_nby[f]+2,PML_nbz[f]+2))
#define PML_HX(f,i,j,k)   PML_HX(f,OFF3(i,j,k,PML_nbx[f]+2,PML_nby[f]+2,PML_nbz[f]+2))
#define PML_HY(f,i,j,k)   PML_HY(f,OFF3(i,j,k,PML_nbx[f]+2,PML_nby[f]+2,PML_nbz[f]+2))
#define PML_HZ(f,i,j,k)   PML_HZ(f,OFF3(i,j,k,PML_nbx[f]+2,PML_nby[f]+2,PML_nbz[f]+2))
#define PML_BHX(f,i,j,k)  PML_BHX(f,OFF3(i,j,k,PML_nbx[f]+2,PML_nby[f]+2,PML_nbz[f]+2))
#define PML_BHY(f,i,j,k)  PML_BHY(f,OFF3(i,j,k,PML_nbx[f]+2,PML_nby[f]+2,PML_nbz[f]+2))
#define PML_BHZ(f,i,j,k)  PML_BHZ(f,OFF3(i,j,k,PML_nbx[f]+2,PML_nby[f]+2,PML_nbz[f]+2))

And if you have any document about advaced gestion of memory, it’s be welcome

Hi Saad,

You should consider contacting the authors of this code since defining a macro to itself doesn’t make a lot sense. Perhaps your missing a configuration step?

And if you have any document about advaced gestion of memory, it’s be welcome

Sorry, but I’m not sure what type of documentation your looking for? Can you be more specific.

Thanks,
Mat

advanced documentation , memory allocation
Thank’s mat,