« first day (846 days earlier)      last day (4118 days later) » 

5:00 AM
learnprogramming has changed.
whoa.
where's the python circlejerk
 
@JerryCoffin Okay, so with an FPGA or a CPLD I'd have to program it myself using the tools provided and then build on top of that by accessing it directly?
 
@ThePhD CPLD is "complex programmable logic device". FPGA is "Field programmable gate array". Both give you programmable logic, so you can (virtually) wire together arbitrary logic and (for example) design your own microprocessor. CPLDs tend to be stronger on the I/O side, FPGAs better for things like processing.
 
Okay. I think that'll do the trick then if I don't go the Arduino Micro route.
It'll take a shitload of learning to make it work though, but I'm ready for it!
... IN a few months. Back to watching DirectX laugh at me. ;~;
 
You probably want an FPGA. CPLDs are not marketed to hobbyists, and usually go into a design after it's been thoroughly prototyped.
 
Ookay, so I'll lookg into FPGAs too.
Man this is a lot of reading guys, slow down. @__@
 
5:06 AM
But FPGAs are neat and you can get a kit for <$100 if memory serves. The Xilinx IDE is/was free and you can simulate everything.
 
That's still quite a lot to learn...
 
Well, you should probably learn assembly before tackling sequential logic circuits. :)
 
=[
You're killing me here. ;~;
But I guess this is the price to pay for getting To The Metal.
 
@Potatoswatter Yup -- Altera also has a free IDE.
 
I wonder how much an Arduino Micro sells for..
36 bucks?
Seriously?
 
5:12 AM
@ThePhD Yes, it definitely is. The hard part is that it requires an entirely different mind-set than normal programming (though programming for massive parallelism is closer to hardware).
 
Oh, it's only 24.10 dollars from 18 Euros.
...That's not expensive at all.
Reading directly at the Arduino Micro might be enough because the Arduino Micro is tiny.
 
You can get others for a little less. digilentinc.com/Products/…
 
I THINK I PROGRAMMED AGAINST THAT ATMEL MODEL BEFORE!
... Oh wait just kidding I lied >>;
But,
it has JTAG, which I'm sort of used to after dealing with the HP 20-B
 
1
Q: Can constant objects with static storage duration and equal, constant initializers be coalesced?

icktoofayConsider two objects with static storage duration and equal, constant initializers: static const int a = 50; static const int b = 50; Is it valid for a compiler to combine these such that &a == &b? (For context, I was thinking of using static constant objects to get unique addresses t...

^^ Interesting...
 
So then now the question would be sensors...
Pressure sensors, things that can sense when there's an external force applied to it.
 
25 lbs max pressure...
Lol
I search "how hard can a human squeeze"
the results: "Girls squeezes guy testicle really hard and he dies"
Gee, thanks google.
 
@ThePhD Women. Can't live with them, can't shoot them.
 
@JerryCoffin But they can squeeze your balls really hard and you'll die of a mass-adrenaline cardiac arrest.
 
user1357851
what is the difference in linking between: 1) extern int c; 2) static int a= doA (); int doA() { return 3;} & 3) int b = doB(); int doB() {return 5;}
 
Okay, so from a bunch of stuff it seems like the limit of human squeezing is like 150 pounds of pressure.
I guess I should see if I can find sensors that can handle that kind of squeeze.
 
5:23 AM
@Mysticial No. The addresses are guaranteed to be different.
 
@LucDanton Oh they are? Interesting...
@LucDanton Make an answer then.
 
I don't know how compilers are good at substituting false for the result of that equality and not produce any object at all.
@Mysticial Meh.
 
Its definitely used for aliasing analysis.
But it won't matter since it's const.
 
@ThePhD May not be necessary -- could use a "reverse lever" (so to speak) at, say, 10:1, so 150 pound squeeze translates to 15 pounds on the sensor.
 
@Mysticial Surprisingly there is no 'is the address of an object unique' question already.
 
5:27 AM
@LucDanton It's comparing addresses of unrelated objects -- no defined results (keep in mind this is C, not C++, so you can't get around that with std::less either).
 
I would have expected as such tbh.
@JerryCoffin Untrue.
You can't use the relational operators but you can use the (in)equality operators. Which is dumb because you can then scour all addresses linearly.
Let me dig a silly example up.
(I don't intend to quote the Standard because that's not as interesting.)
 
@ThePhD It makes sense. I think the real issue I'm having is say I'm making a memory allocator, where this sort of pointer "hackery" is common
Like you can't do pointer arithmetic on void*, so do authors reinterpret_cast back and forth between void*s and char*s and do pointer arithmetic on that or what?
 
@LucDanton Oops -- quite right. My apologies.
 
@JerryCoffin Tbh I've forgotten that more than once.
 
@Insilico They probably just keep a char* or byte* in memory.
There's no need to repeatedly go from void* to byte*. You can't perform arithmetic on void* anyways, because its an incomplete type.
However, void* is convertible to all types of pointers and returns the 'true address', so to speak, of a pointer.
 
5:32 AM
In the case of the msg_hdr_t thingy I mentioned earlier, if I converted the void* pointer returned from data() to a char* via static_cast, does it perserve the pointer address?
 
Some select morsels that have really ingrained these rules in my memory:
Jun 10 '11 at 0:48, by Johannes Schaub - litb
though int a = 0; int b = 0; if(&a + 1 == &b) { int *c = &a + 1 + 1; *(c-1) = 10; } assert(b == 10); is valid non-UB code
Jun 10 '11 at 0:51, by Johannes Schaub - litb
&a+2 is UB but &a+1+1 is not
 
Or will I run afoul of some kind of pointer aliasing rule?
 
Well, it's not like you're incrementing based on types that the memory is not.
 
Because it seems like the trick msg_hdr_t uses would be a good way to simulate variable length structs in C++ without using flexible array members, which is a C99-only feature.
 
@Insilico Pointer conversion rules will trip up you, and then aliasing rules will trip you up, but they're separate, sort of.
(I'm speaking in general, I don't really know what's going on here.)
 
5:34 AM
@ThePhD I think it's all right -- the standard requires that void * and char * have the same representation, and allows aliasing anything else with a char *.
 
that, and ALL pointers can be traversed using char*. I'm pretty sure the regular C (not ++) standard mandates that everything can go to and from char*.
 
@Insilico: you're allowed to round-trip a pointer from T* to void* back to T*
 
^ What Jerry Said @Insilico
 
@rici But in this case we're going from msg_hdr_t* (pointing to a nonexistent msg_hdr_t, I might add) to a void* to a char*. That's what's tripping me up.
 
@ThePhD I believe C++ allows it too, as of C++11.
 
5:36 AM
@Insilico: is msg_hdr_t a POD?
 
@Insilico It's been around for years -- before C99 blessed it as a flexible array member it was generally known as "the struct hack". Basic conclusion: officially it's UB, but nobody's ever seen a real implementation where it's a problem (and it's common enough it'd probably become widely known in a hurry if it existed).
 
@rici I think so. msg_hdr_t comes from here: boost.org/doc/libs/1_48_0/boost/interprocess/ipc/…
 
@Insilico Going to a non-existent msg_hdr_t just means you've properly jumped over the bytes of the type. Downcasting to void*, because of the standard, means the address is directly representable as char*. So it's safe.
 
@jerryCoffin, i think the struct hack is not UB, but I could be wrong.
 
@JerryCoffin I thought the struct hack was when you had a char buffer[1]; or a char buffer[0]; at the end of the struct.
 
5:39 AM
yeah, me too
 
Does having a function like void* data() { return this+1; } count as a struct hack?
 
buffer[1]
 
@rici It was discussed pretty heavily on comp.std.c years ago, and the conclusion reached was that it was. You're accessing beyond the declared size of the array you define at the end of the struct, so a compiler could do bounds checking, and if so it's free to throw an exception (or whatever) when you do.
 
@JerryCoffin ah, ok
 
@Insilico Yes -- I thought that was what you had. Apparently not though?
 
5:40 AM
no, he's got a struct{} with a data() function as above
 
@Insilico Not how it was/is normally done, but certainly the same basic idea.
 
that's certainly UB, I believe
 
@JerryCoffin No, I was talking about the msg_hdr_t structure in Boost's IPC library. The library allocates a chunk of memory with size > sizeof(msg_hdr_t) and overlays a msg_hdr_t at the beginning of the chunk. (msg_hdr_t is a POD, I believe)
And to get to the rest of the chunk that appears after msg_hdr_t you call data() on it, which does the return this+1; thing that apparently correctly returns the pointer to the payload that occurs after the header
 
assuming the payload isn't of a type which requires more alignment
 
But if the chunk is all allocated in one go, there's no need to do any extra alignment, is there?
 
5:43 AM
the payload is at an offset from the beginning of the allocation.
 
@Insilico If the chunk is allocated dynamically, I think it's probably all right, even technically, as long as you treat it as a pointer to (signed | unsigned) char.
 
yes, if you treated the payload as char[], it's fine.
but then you might as well return char* from data(), rather than void*
 
@rici void* is more expressive of the fact that it can be anything.
 
yeah, but it can't be anything. it can only be anything not more aligned than a msg_hdr_t
 
Plus, since the whole thing is allocated in some big byte* chunk, there's no need for aliasing issues if you write / read to it uniformly.
 
5:45 AM
msg_hdr_t is a size_t and an int, which could be 12 bytes in some architecture.
so that wouldn't work if the payload required 16-byte alignment
 
@JerryCoffin Depends how it was obtained. The result of a new expression for instance is a T* which arguably is not fair game to alias (aforementioned exceptions notwithstanding).
 
Not necessarily.
 
@rici ...or anything more than 4.
 
@rici In that case, the compiler would insert extra padding in the msg_hdr_t structure, since size_t I think has stricter alignment requirements than an int, typically.
 
... actually, i guess it would
it wouldn't work if payload required 32-byte alignment
 
5:46 AM
Hence the usual advice to explicitly use new char[size] or operator new(size) to allocate 'untyped' memory.
 
@LucDanton Right -- but since they're over-allocating, I'm assuming they must be using ::operator new, malloc, or something on that order.
 
If the stream is allocated using byte* alldata = newbyte[5000];, then you insert a msg_hdr_t in the stream, then it'll be type safe if you read and write to it at the same byte* or void* addresses.
 
@JerryCoffin Do you happen to know where in the C++ standard it says that void* and char* have the same representation?
 
At that point, you're doing the byte-aligning yourself.
 
the point of the struct hack is that you get the alignment and offset right, because the struct is {headerT hdr; dataT data[1]; }
then the struct has the correct alignment based on the strong of headerT and dataT, and dataT is also at the right padded offset.
 
5:47 AM
@Insilico Not off the top of my head, no. Actually, not sure if it's directly in C++ or just in the C standard.
 
and the struct prefix rule makes that layout the same as {headerT hdr; dataT data[N]; } for N > 1
 
You know
If you really want to be typesafe
you could just cheat with Templates.
 
i don't think the c++ standard does say that, @Insilico
 
So it seems to me that if given a pointer to a msg_hdr_t, correctly initialized in a properly allocated chunk of memory, then I can do a (this+1) --> void* --> char* conversion then be able to do whatever raunchy pointer arithmetic on the chunk after the msg_hdr_t header?
 
@Insilico You'd need a lawyer to justify the aliasing.
And I don't mean 'lawyer' as in 'intimate with the rules and cunning', I mean that as 'underhanded and brutally cunning'.
 
5:50 AM
@LucDanton And that goes back to my concern earlier. I'm not 100% sure if it's legal by the C++ standard or not.
 
@Insilico A quick check shows it's at §3.9.2/4: "An object of type cv void* shall have the same representation and alignment requirements as cv char*."
 
@Insilico As I've said, pointer gymnastics and aliasing considerations are separate, sort of.
But if this is the struct hack then it's at best a gray area. I'm of the opinion that it's not allowed.
Of course, you can always do *(p+1+1+1+1) and then maybe it's magically allowed... As I've said, we need a bastard lawyer.
 
the thing that is allowed is what's necessary to make std::vector work, which is that you can figure out how big N dataT's are, allocate a char[] of that size, and then alias the N dataT's on top of it
 
Looking through the Boost source, they pass the return value of data() to memcpy(), which I'm sure does pointer arithmetic.
 
yes, that's the other thing. you're allowed to copy bytewise.
 
5:54 AM
So I wonder if such pointer gymnastics is allowed, since otherwise memcpy() can't possibly work.
 
memcpy does not need to be expressible in C++
 
Is there a reason why I don't see code and only hear second-hand descriptions of it?
 
@LucDanton We're talking about this: boost.org/doc/libs/1_53_0/boost/interprocess/ipc/… Specifically, the fact that it overlays a msg_hdr_t onto a block of memory and the payload that follows it contains some user-provided data.
 
@Insilico If memory serves, memcpy is required to (work as if it) copies char by char, so neither alignment nor aliasing comes into the picture.
 
@JerryCoffin, yes, I think that's true.
and copying char by char is allowed aside from atomics, I guess.
 
5:57 AM
@rici In C. In C++, it's only good for POD (oops -- standard layout, I guess now).
 
@Insilico @JerryCoffin @LucDanton My best 'safe' way to access data after the a header: ideone.com/p5ZG8p
 
"trivially copyable" ?
"For any object (other than a base-class subobject) of trivially copyable type T, whether or not the object
holds a valid value of type T, the underlying bytes (1.7) making up the object can be copied into an array
of char or unsigned char."
 
@rici Yeah, that's what I was trying to think of.
 
Where is the allocation?
 
Woops
 
5:59 AM
@LucDanton I think in Boost's IPC library the allocation happens somewhere else.
 
I was returning &offset instead of &offset[0].
Big derps.
 
@ThePhD That still uses the "struct hack", no?
 
Pretty much.
I don't see another way to do it.
It's either that or jumping over the header by itself and just starting to read at the end of the header.
Or getting the offset from a combination of the header and the first type T.
 
@LucDanton Search for initialize_memory.
 
The crux of the issue is whether or not doing a return this+1; where this is a msg_hdr_t* then converting that to void* or char* is legal C++.
 
6:01 AM
Yes that's fine.
 
@Insilico msg_hdr_t is a PoD, so by what was already posted, yes.
 
converting it to void* is fine
or char*
the question is whether you can dereference the char*
 
I'm just making sure I'm not causing aliasing violations or nasal demons or something like that.
 
Haha, nasal demons.
 
@LucDanton Oops -- nope, not there after all.
 
6:02 AM
What do they do, twist your nose hairs?
 
I'm not sure for char* actually. You might need to know there is an object at that address.
(Hence why I'm wondering about the allocation.)
 
@LucDanton: the pointer is ok, because a pointer can point one beyond an object.
but such a pointer is not dereferenceable
 
@LucDanton There won't be an object there.
 
@Insilico I don't buy it, why would they need this+1 at all then?
 
24 mins ago, by In silico
@JerryCoffin No, I was talking about the msg_hdr_t structure in Boost's IPC library. The library allocates a chunk of memory with size > sizeof(msg_hdr_t) and overlays a msg_hdr_t at the beginning of the chunk. (msg_hdr_t is a POD, I believe)
23 mins ago, by In silico
And to get to the rest of the chunk that appears after msg_hdr_t you call data() on it, which does the return this+1; thing that apparently correctly returns the pointer to the payload that occurs after the header
msg_hdr_t holds the header, and the memory after that carries a payload which is the message provided by the application.
 
6:05 AM
So, you're saying there are objects then.
 
and what's the type of the payload?
 
Quick question:
If I `new` a `Foo`, would the memory be deallocated when I `delete` it from a `void*`?
 
@LucDanton Doing some more looking, it appears the allocation is done in shared memory, so it's almost certainly outside the scope of the standard.
 
@rici I think it's just a bunch of bytes. It's for interprocess communication, apparently.
 
@JerryCoffin Oh hum...
@Insilico char are objects as well you intolerant bastard!
 
6:07 AM
ipc is not limited to chars, but if that's what it is, it should be fine. and what jerry said.
 
@MarkGarcia You can't use delete with a pointer to void.
 
@LucDanton Oh. Thanks.
 
@LucDanton I believe if you search for "inline message_queue_t<VoidPointer>::message_queue_t(open_or_create_t", you'll find the actual allocation right afterwards.
 
@rici There are no guarantees on the result of such a conversion if there is no object at that address (which is fine because there is nothing useful to do with such a value).
 
What if I did a return reinterpret_cast<char*>(this+1); in a msg_hdr_t instead of doing a msg_hdr_t* to void* to char* conversion?
What kind of insanity would that entail?
 
6:10 AM
@Insilico I don't think it would change much.
 
Not much. I'm of the opinion that if anything, the issue is with the Standard in that respect, it could use better wording.
 
Wtf
I just noticed: why did the message from Robot saying somebody does things the worst way possible have 13 stars? D:
 
Seeing that Boost is peer-reviewed, and there doesn't seem to be any weird compiler-specific preprocessor macros for the code, it apparently works on virtually any compiler.
 
Ahem.
 
@ThePhD Oh, Robot was referring to you? tempted to star it
 
6:12 AM
... No, um.
What I meant to say was
he was talking about
 
@JerryCoffin Thanks for looking. I'm investigating where this goes.
 
some random noob
Clearly not me. >_>
I'm obv. a pro.
 
@LucDanton: i think the intention of the standard is that the one-past-the-end pointer should point to something, even if it is unrelated.
@LucDanton, although in this case, one-past-the-end doesn't technically apply because it only applies to arrays.
 
The issue is not that value. It is the result of converting that value.
 
look at the footnote at the end of 5.7
82) Another way to approach pointer arithmetic is first to convert the pointer(s) to character pointer(s): In this scheme the
integral value of the expression added to or subtracted from the converted pointer is first multiplied by the size of the object
originally pointed to, and the resulting pointer is converted back to the original type. For pointer subtraction, the result of the
difference between the character pointers is similarly divided by the size of the object originally pointed to.
When viewed in this way, an implementation need only provide one extra byte (which might overlap a
 
6:17 AM
Given int i[1];, there is nothing exotic about i+1, or static_cast<void>(i+1); but what can you tell me about static_cast<char*>(static_cast<void>(i+1))?
 
s/void/void*
 
that you can cast it back to an int*
 
Or what if I did char* getPayload() { return reinterpret_cast<char*>(this) + sizeof(msg_hdr_t); }? Would this be more "justifiable" somehow?
 
and it will have the same value as an int* that it had when you started.
 
@rici Please substantiate that.
 
6:19 AM
void* and char* have the same representation, jerry coffin pasted the section a while ago.
let me see if i can find the round-trip rule in a few seconds.
 
@Insilico That just seems like doing the same work as what this + 1 for a msg_hdr_t* ...
But, hey. If it makes you feel more safe, go ahead. :P
 
Spoiler alert: that rule is from pointer to object type to pointer to void and then back.
 
yes, but you started with an int*
so you had a pointer to object type
 
@ThePhD Right, but it seems to not violate aliasing rules, where in the case of doing a return this+1 then converting the resulting msg_char_t* to a char*, we can't come to a conclusion about its legality w.r.t. aliasing rules.
 
Only tells us about the result of static_cast<int*>(static_cast<void*>(i+1))
What we have is the result of going to char*. What now?
 
6:21 AM
that's where the fact that char* and void* have the same representation is important.
 
No, it is not.
 
@Insilico I guess that would be safer.
Might as well do it that way.
 
That tells us things like they have the same size, the same alignment, and that all valid object representations of one are also valid object representations for the other.
 
Of course, you're assuming that msg_hdr_t is PoD (standard-layout) and thus allowed to be converted from char* to msg_hdr_t* at that specific address and will not alias or fuck up. :P
 
It doesn't tell us that any value of one is 'interchangeable' with the other.
 
6:23 AM
i read this as bitwise identical: "An object of type cv void* shall have the same representation and alignment requirements as cv char*."
but maybe i'm not reading it correctly.
 
unsigned and signed integral types have similar representation but you can't just convert from one to the other always.
 
@LucDanton Based on arguments I've followed in comp.std.c and comp.std.c++, there's considerable disagreement within the committees about whether it is or not, but it generally seems to lean toward the "it is" side.
 
To be honest, we're worrying about nothing, because virutally every compiler in the end supports this +1 to void* to char*. Trying to make sure it's standards-proof is not worth much if the compilers don't respect it anyhow.
 
similar is not the same as same
 
@JerryCoffin You mean it's underworded?
 
6:24 AM
@ThePhD Right, and I figured as much since Boost doesn't need to add in compiler-specific macros for that piece of code.
 
unsigned and signed types only have the same representation for non-negative values. that is clear.
 
That would save us some sanity points, and I need those badly.
 
and you can round-trip positive values.
 
@Insilico Dooo iiiit. <3
 
@ThePhD If it breaks in the future, I'm blaming it on you.
 
6:25 AM
@rici Sorry, I did mean 'same' here, and I got the example wrong -- I was thinking of the char types.
 
I'll take the blame gladly.
Besides, this is an issue that's been present since C++ in the early days.
 
@LucDanton Yes, probably. I haven't followed them in a while, but when I did, nobody seemed at all willing to work on better wording though.
 
By now, every smart compiler has already hammered out how it wants to handle it.
 
Let me see if I understand the aliasing rules correctly. A char* can alias anything, correct?
 
@Insilico or unsigned char* !
 
6:27 AM
So doing a msg_hdr_t* to a char* cast via reinterpret_cast is not an aliasing violation?
 
@LucDanton are you claiming that char has the same representation as either signed char or unsigned char, but that you can't round-trip it to either?
@LucDanton: if so, can you substantiate that?
 
As opposed to say, a msg_hdr_t* to a double* cast via reinterpret_cast?
 
@Insilico You can't ever do an aliasing violation from doing a pointer conversion.
@rici Presumably sourcing "A char, a signed char, and an unsigned char occupy the same amount of storage and have the same alignment requirements (3.11); that is, they have the same object representation." is not at hand here.
 
@LucDanton So aliasing violations come from dereferencing aliased pointers?
 
@Insilico Yes. First, you need to 'follow the pointer' to check if the conversions and pointer operations were valid. Then, you check whether you have an aliasing issue or not. Honestly the hairy thing is the former, not the latter.
 
6:31 AM
Juuuuuust do it.
 
@lucDanton: interesting definition of "object representation". In that case, the quote about char* is not sufficient.
 
You've spent nearly an hour worrying about something that - honestly - isn't that big of a deal.
 
@ThePhD To be quite honest this one of the more productive discussions we've had on Lounge<C++>. And it's actually about C++. That is an achievement.
 
@rici I've been thinking about that roundtrip and I'm not sure that's really what should be considered here.
 
@Insilico I suppose so... still. Was it really necessary to go into standardese? My head kinda aches. :c
 
6:32 AM
Converting a prvalue of type
“pointer to T1” to the type “pointer to T2” (where T1 and T2 are object types and where the alignment
requirements of T2 are no stricter than those of T1) and back to its original type yields the original pointer
value.
 
@ThePhD Yes.
 
so int* -> char* -> int* is legit
 
@Insilico Okay. So are you gonna do it?
ARE YOU GONNA TAKE THE CHANCE AND char* ?!
WILL YOU GO WITH ME TO THE DANGERZOOOONE?!
 
@LucDanton that was 5.2.10p7
 
@ThePhD I've already decided on using char*. That's not the issue. lol
 
6:34 AM
@rici The title of which is...?
 
reinterpret_cast
 
Oh, you amuse me so much.
 
I'll just do a return reinterpret_cast<char*>(this) + sizeof(header); and hope for the best.
 
Still!
 
@Insilico Yaaay!
 
6:35 AM
In that case we're dealing with pod types.
 
ah, you did a static cast
 
I promise everything will be just fine. :D
 
@rici That was not an accident.
 
yes, int* and char* are both pods
i mean, int and char. well, also int and char
 
> When a prvalue v of type “pointer to T1” is converted to the type “pointer to cv T2”, the result is static_cast<cv T2*>(static_cast<cv void*>(v)) if both T1 and T2 are standard-layout types (3.9) and the alignment requirements of T2 are no stricter than those of T1, or if either type is void.
Completely overlooked that this is applies to pointers to standard-layout or void!
Btw that's C++11 wording (for reinterpret_cast, I believe 2003 doesn't have that, or in this form. At the very least it was tidied up.
 
6:37 AM
could be. i don't have c++03 handy
anyway, it's clear that it always worked, regardless of what the standard ever said.
 
So the specs for reinterpet_cast also dictate what the results of static_cast do, some of the time. Remember what I said about sanity points?
@rici Yes, I agree.
 
well, i'm glad we got to that point. i can go to bed happy now.
 
...
Wow.
WOW.
SO NOW D3D IS ACCESSING A NULL PTR SOMEWHERE WITHOUT MY PERMISSION.
 
This tidying up was a formality, to keep up to date to what implementations were already doing, and users were expecting. Wasn't a surprise.
 
YOu know what? Fuck you D3D. Fuck you Microsoft. I'm entering your fucking competition with OpenGL.
 
6:39 AM
Yes. 03 says:
A pointer to an object can be explicitly converted to a pointer to an object of different type.65) Except that converting an rvalue of type “pointer to T1” to the type “pointer to T2” (where T1 and T2 are object types and where the alignment requirements of T2 are no stricter than those of T1) and back to its original type yields the original pointer value, the result of such a pointer conversion is unspecified.
 
@LucDanton The C++ standard does mention in a note somewhere that the results of reinterpret_cast is meant to be "unsurprising" to users, whatever that means.
@ThePhD Have you considered the possibility that it's because you passed a null pointer somewhere?
 
@Insilico Too bad I throw an assert on all null arguments, so no. It's not my fault. ._.
 
@Insilico In turn Hell++ assumes its users won't be surprised by anything (anymore)!
 
> A pointer can be explicitly converted to any integral type large enough to hold it. The mapping function is implementation-defined [Note: it is intended to be unsurprising to those who know the addressing structure of the underlying machine.]
@ThePhD You know that asserts are turned off in release mode, right?
 
yeah, that's to integers, not to other pointers. Although it would be surprising if the rules were different :)
 
6:41 AM
@LucDanton ...but nobody expects the Spanish Inquisition!
 
create a debug context. it makes a huge difference
 
is it ok to ask short questions here?
 
@Insilico I'm not in release. I'm not suicidal.
 
Man, do you guys still want to explore this further? I'm getting dizzy :(
 
@doug65536 I do have a debug context on.
 
6:42 AM
ok, is it actually a null pointer, or is it an AV at some address?
 
@LucDanton I think we passed the point of pointlessness (!) at least 20 minutes ago.
 
@LucDanton Well, I already have my question-turned-into-a-protracted-discussion answered, so no. :-)
 
D3D hasn't been warning me for the past week despite it bemoaning and fucking up all my model geometry.
@LucDanton Seee! This is what Standarese does to people.
 
This is one of my previous studies/forays into pointer conversions & aliasing rules. It's really not an answer that I'm fond of, the thing was too painful to write. Feel free not to read it to the end, really!
 
yeah, you should try hanging out in a courtroom sometime.
 
6:43 AM
Not one error code, it populates all my pointers of D3D interfaces properly,
and yet it still blows shit up.
 
you are probably messing up a refcount if it's throwing AV
 
Oh yeah, and I had to cross-reference lifetime rules as well. I'm starting to hurt again.
 
Hello
 
@M3taSpl0it Hi there
 
it's always seemed to me that way too much of the hair splitting in this sort of discussion has to do with being prepared to deal with architectures which don't exist in the real world, and will never exist in the real world.
it's the standardese equivalent of over-engineering interfaces, to which my response has always been YAGNI
 
6:45 AM
@Insilico How're you? :)
 
but that doesn't stop me from stupidly jumping into the fray from time to time. probably comes from having grown up in a legal environment.
 
I ... I just quit.
I don't understand anything anymore.
 
anything is simply something which ain't nothing.
 
@rici You might be surprised at how complex some real architectures really were.
 
jerryCoffin, i've been in this game for more than 40 years, and i've programmed ibm 360 channels.
 
6:47 AM
@Insilico I need little help with ADL , it's written in the C++ standard If T is a class type (including unions), its associated classes are: the class itself,.... , So does ADL looks up inside the class to find the function?
 
I would think that only really matters for operators. Let me freshen up on ADL though.
 
i've programmed pdp-6/10 where character pointers are actually bit pointers
 
Access violation reading location 0x083872D8.
 
so nothing would really surprise me.
 
^ Does anything about that address stick out to anyome?
It looks regular to me.
 
6:49 AM
@LucDanton I checked , they just wrote postfix expression in function call
 
@M3taSpl0it Ah, that wording may be here for friend function and function templates.
 
it's kind of low, probably a heap allocation
@thephd does it reproduce? you can find out the exact call stack that allocated that memory with cdb
 
In any case, if you have namespace ns { struct foo { void bar(); }; } then foo f; bar(f); does not resolve to a call to foo::bar. It is an error.
 
@LucDanton indeed ADL never considers member functions including static ones but I couldn't find that in standard
 
@rici Yes, and they were a little odd, but not terribly. Some were quite a bit stranger -- Unisys had a couple different rather strange ones. I can't remember the name, but there was one with some object orientation and (especially) object storage support in hardware in the late 80s or so. Dataflow machines also had some pretty strange stuff (instead of instructions in linear memory, almost everything was packets in CAM).
 
6:57 AM
@doug65536 The address changes each time.
@doug65536 How do you go back with cdb to track it?
 
with gflags you can make windows record the stack trace for all allocations, and in the debugger, you can make it show what stack was the last to allocate that memory
 
YOu're probably talking about functions and command line that goes far beyond the scope of my knowledge at hte moment.
 
usually gives you a good idea of where the error is
 
@JerryCoffin iirc lisp machines distinguished between pointers and integers. many things have been tried.
 

« first day (846 days earlier)      last day (4118 days later) »