This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/25845] want optional warning for non-constant declarations that could be constant
- From: "pinskia at physics dot uc dot edu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 18 Jan 2006 19:33:26 -0000
- Subject: [Bug c++/25845] want optional warning for non-constant declarations that could be constant
- References: <bug-25845-315@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #9 from pinskia at gcc dot gnu dot org 2006-01-18 19:33 -------
Subject: Re: want optional warning for non-constant declarations that could be
constant
> > int f(const int *a, int *b)
> > {
> > *b = 1;
> > return *a;
> > }
> >
> > a and b can alias and there is no way around that at all because that is
> > what the C++ standard says.
>
> In this case the compiler should warn because a could be declared "const int *
> const" and b could be declared "int * const".
That still does not change the fact that a could point to the same location as
b is pointing too.
-- Pinski
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25845