H
Howard
JKop said:When I have the likes of:
struct Blah
{
int a;
double b;
int* p_k;
float** p_p_f;
};
I should be able to set it to whatever the hell I please!
I think the point here is that we're now talking about "implementation
defined" behavior. Since you're not (yet) dereferencing the pointer(s),
there's no "undefined behavior" going on. But it's certainly possible that
you could be compiling for a platform that implements addresses in adress
registers, isn't it? In that case, wouldn't it behoove (I love that word
) them to disallow somehow any assignment of an address which is not
valid?
Implementation defined behavior is simply where the Standard allows a
compiler to take the actions it needs to take under the given conditions,
rather than specify them explicitly. Assuming that this actually *is*
implementation-defined (I really don't know for sure, not having the
standard handy), it just means that you'd have to check your own compiler(s)
before attempting that kind of action. And I'm sure you'll agree that
explictly setting a pointer value to be anything other than NULL, or the
address of an existing object (or its member), is pretty senseless, eh?
I'd like some clarity on the issue. Will the following behave identically
on
all implementations, ie. will it output "I'm not a shit implementation!"
on
all platforms?:
int main()
{
bool* p_boolean = reinterpret_cast<bool* const>(92729);
std::cout << "I'm not a shit implementation!";
}
I have absolutely NO idea if it's actually done that way on any specific
platform, but there's likely to be far more platforms out there than I care
to list, let alone test on, dontcha think?
-Howard