Commit d780189f by James Dennett Committed by Jason Merrill

re PR c++/39415 (static_cast used as downcast can silently lose const)

	PR c++/39415
	* typeck.c (build_static_cast_1): Convert to the target type
	when doing static_cast<cv Derived*>(Base*).

From-SVN: r166667
parent 47c21725
2010-11-12 James Dennett <jdennett@google.com>
PR/39415
* typeck.c (build_static_cast_1): Convert to the target type
when doing static_cast<cv Derived*>(Base*).
2010-11-10 Jason Merrill <jason@redhat.com>
PR c++/46420
......
......@@ -5884,7 +5884,8 @@ build_static_cast_1 (tree type, tree expr, bool c_cast_p,
base = lookup_base (TREE_TYPE (type), TREE_TYPE (intype),
c_cast_p ? ba_unique : ba_check,
NULL);
return build_base_path (MINUS_EXPR, expr, base, /*nonnull=*/false);
expr = build_base_path (MINUS_EXPR, expr, base, /*nonnull=*/false);
return cp_fold_convert(type, expr);
}
if ((TYPE_PTRMEM_P (type) && TYPE_PTRMEM_P (intype))
......
2010-11-12 James Dennett <jdennett@google.com>
PR c++/39415
* g++.dg/expr/static_cast7.C: New.
2010-11-12 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
* lib/prune.exp (prune_gcc_output): Ignore IRIX 6 linker multiline
......
// Regression test for bug 39415 (and its duplicate 44916).
struct S {};
struct T : S {};
int f(const T*) {}
void f(T*);
int main() {
S* s(0);
int a = f(static_cast<const T*>(s));
int b = f(static_cast<const T*>(0));
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment