Bug 55878 - [4.7/4.8 Regression] --enable-checking=yes rejection of typeid
Summary: [4.7/4.8 Regression] --enable-checking=yes rejection of typeid
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.8.0
: P1 normal
Target Milestone: 4.8.0
Assignee: Jason Merrill
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2013-01-04 17:50 UTC by Jakub Jelinek
Modified: 2013-01-10 02:59 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2013-01-10 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jakub Jelinek 2013-01-04 17:50:28 UTC
// { dg-do compile }
// { dg-options "-std=gnu++0x" }

#include <typeinfo>

struct S;

template <typename T>
static bool fn (S *s)
{
  return typeid (*s) == typeid (T);
}

struct S
{
};

bool x = fn<S> (__null);

is rejected with --enable-checking=yes compilers (but accepted with release checking compilers), starting with
http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=173679

Is this code valid C++ or not, i.e. is the FE allowed to warn about incomplete types even in the uninstantiated template?
Comment 1 Richard Biener 2013-01-07 15:48:24 UTC
Definitely P1, we should be consistent with accepting/rejecting code with/without checking enabled.
Comment 2 Jason Merrill 2013-01-07 22:40:22 UTC
This is a bug that only appears with --enable-checking; I don't see how that merits P1.
Comment 3 Jason Merrill 2013-01-10 02:54:43 UTC
Author: jason
Date: Thu Jan 10 02:54:39 2013
New Revision: 195075

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=195075
Log:
	PR c++/55878
	* rtti.c (build_typeid, get_typeid): Add complain parm.
	(get_tinfo_decl_dynamic): Likewise.
	* cp-tree.h, parser.c, pt.c: Adjust.

Added:
    trunk/gcc/testsuite/g++.dg/template/typeid1.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/cp-tree.h
    trunk/gcc/cp/parser.c
    trunk/gcc/cp/pt.c
    trunk/gcc/cp/rtti.c
Comment 4 Jason Merrill 2013-01-10 02:59:22 UTC
Fixed for 4.8.  No point fixing in 4.7 a bug that only comes up with --enable-checking.