Bug 32260 - [4.3 Regression] too many warning: dereferencing type-punned pointer will break strict-aliasing rules
[4.3 Regression] too many warning: dereferencing type-punned pointer will bre...
Status: RESOLVED FIXED
Product: gcc
Classification: Unclassified
Component: c++
4.3.0
: P2 normal
: 4.3.0
Assigned To: Jakub Jelinek
: alias, diagnostic
: 33902 34066 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2007-06-08 18:44 UTC by Sylvain Pion
Modified: 2007-11-11 14:04 UTC (History)
8 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2007-11-01 11:57:35


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sylvain Pion 2007-06-08 18:44:02 UTC
The following code, compiled with -O2 -Wall (g++ 4.3 as of 20070607),
produces the following unexpected/annoying warning:

test_typeinfo.cpp: In function 'int main()':
test_typeinfo.cpp:5: warning: dereferencing type-punned pointer will break strict-aliasing rules
test_typeinfo.cpp:5: warning: unused variable 't'


~> cat test_typeinfo.cpp 
#include <typeinfo>

int main()
{
  const std::type_info & t = typeid(int);
}


Is this really meant to warn for such a code???
Comment 1 Andrew Pinski 2007-06-11 21:19:44 UTC
Confirmed, I have not looked into this close enough but this is a front-end bug as the type (and aliasing set) of the typeid variable is different from std::type_info's.
Comment 2 Paolo Carlini 2007-09-28 17:04:10 UTC
Short term at least, could be considered a duplicate of PR32256 (and PR32368).
Comment 3 Paolo Carlini 2007-10-26 09:00:49 UTC
*** Bug 33902 has been marked as a duplicate of this bug. ***
Comment 4 Jakub Jelinek 2007-11-01 11:57:35 UTC
Testing a fix.
Comment 5 Jakub Jelinek 2007-11-01 22:50:49 UTC
Subject: Bug 32260

Author: jakub
Date: Thu Nov  1 22:50:32 2007
New Revision: 129835

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=129835
Log:
	PR c++/32260
	* rtti.c (enum_tinfo_kind): Fix TK_TYPE_INFO_TYPE comment.
	(typeid_ok_p): Use the same alias set for abi::__type_info_pseudo
	as for std::type_info.

	* g++.dg/rtti/typeid7.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/rtti/typeid7.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/rtti.c
    trunk/gcc/testsuite/ChangeLog

Comment 6 Jakub Jelinek 2007-11-01 23:09:33 UTC
Fixed.
Comment 7 Paolo Carlini 2007-11-11 14:04:14 UTC
*** Bug 34066 has been marked as a duplicate of this bug. ***