[ub] type punning through congruent base class?
Fabio Fracassi
ffracassi at think-cell.com
Thu Dec 19 18:52:27 CET 2013
Hello UB-Experts,
as far as I can see the following (static_cast) is UB:
struct B {
int i;
};
struct D : B {
void foo() { /* access B::i */ }
};
B b;
static_cast<D&>(b).foo();
because of [expr.static.cast] clause 11
first question: is my assessment of the situation correct or is this use legal?
if it is not (legal): could we make it legal or would we run afoul of the aliasing rules?
best regards
Fabio
--
Fabio Fracassi | ffracassi at think-cell.com<mailto:ffracassi at think-cell.com>
Software Engineer
________________________________
think-cell Sales GmbH & Co. KG http://www.think-cell.com<http://www.think-cell.com/>
Chausseestr. 8/E phone / fax +49 30 666473-10 / -19
10115 Berlin, Germany US phone / fax +1 800 891 8091 / +1 212 504 3039
Amtsgericht Berlin-Charlottenburg, HRA 44531 | European Union VAT Id DE815233792
General partner: think-cell Operations GmbH | Amtsgericht Berlin-Charlottenburg, HRB 129917
Directors: Dr. Markus Hannebauer, Dr. Arno Sch?dl
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.open-std.org/pipermail/ub/attachments/20131219/5a040b9e/attachment.html
More information about the ub
mailing list