This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Casts, types, pointers, and ADDR_EXPR
- From: Andrew Pinski <pinskia at physics dot uc dot edu>
- To: GCC List <gcc at gcc dot gnu dot org>
- Cc: Andrew Pinski <pinskia at physics dot uc dot edu>
- Date: Wed, 26 May 2004 21:58:04 -0400
- Subject: Casts, types, pointers, and ADDR_EXPR
I am trying to figure out why these two functions act
differently on the tree level as there is an extra cast
in h1 which I think is extraneous.
int h(int g)
{
const int *x = &g;
return *x;
}
const int h1(const int g)
{
const int *x = &g;
return *x;
}
The reason why I think the cast is extraneous is because
the following code does not produce a cast at all so why
produce one for the address one:
int h2(int g)
{
const int x = g;
return x;
}
Getting rid of these casts would help all other optimizations
and will lower the memory usage of gcc slightly at the same time.
Thanks,
Andrew Pinski
PS yes this is the issue I brought up by my fold patch for
ADDR_EXPR but I would like to better understand why there should be
a cast there as the types in my mind equivalent as there is no cast
from "int" to "const int".