This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: False ODR violation positives on anonymous namespace types
- From: Jan Hubicka <hubicka at ucw dot cz>
- To: Jason Merrill <jason at redhat dot com>
- Cc: Jan Hubicka <hubicka at ucw dot cz>, gcc-patches at gcc dot gnu dot org
- Date: Mon, 11 May 2015 20:05:09 +0200
- Subject: Re: False ODR violation positives on anonymous namespace types
- Authentication-results: sourceware.org; auth=none
- References: <20150511142810 dot GA6584 at kam dot mff dot cuni dot cz> <5550E3D2 dot 2080408 at redhat dot com> <20150511174607 dot GB59663 at kam dot mff dot cuni dot cz> <5550ECB5 dot 8000607 at redhat dot com>
> On 05/11/2015 12:46 PM, Jan Hubicka wrote:
> >Well, my main motivatoin to extend from RECORD_OR_UNION_TYPE_P was to handle
> >enums. But other case I would like to deal with are integer types - i.e. preserve
> >difference between char/signed char/unsigned char/short/int/long/wchar in cases
> >where they structurally coincide.
>
> In what context? Won't you get that from comparing e.g. the field
> types of two definitions of the same class?
If one class define "int foo;" and other "long foo;" we currently do not complain
about ODR on 32bit targets while I think we could.
Other case was the ODR violations dragged by the signed/unsigned:
char switch:
$ cat t.C
char a;
$ ./xgcc -B ./ -O2 t.C -o t1.o -fno-signed-char -c -flto
$ ./xgcc -B ./ -O2 t.C -o t2.o -fsigned-char -c -flto
$ ./xgcc -B ./ -O2 t1.o t2.o -flto -fno-signed-char -flto
<built-in>: warning: type Ãcharà violates one definition rule [-Wodr]
<built-in>: note: a type with different signedness is defined in another translation unit
t.C:1:6: warning: type of Ãaà does not match original declaration
char a;
^
t.C:1:6: note: previously declared here
char a;
^
I also want to use ODR for more fine grained TBAA on LTO and there the differences between
integer types matter more.
Honza
>
> Jason