« first day (1730 days earlier)      last day (3443 days later) » 

13:01
wide
porting to Clang or porting to LLVM?
same thing for Wide
how come?
because Wide makes a very heavy use of Clang to power it
13:08
clearly not.
Enum and IntEnum- pretty much tells you in advance that it's shit
yeah just like enum class and enum
whatever
well, for one, enums in C definitely are shit.
user1804599
@Puppy You clearly have no idea what you are talking about.
user1804599
Why did I unplonk you again?
but secondly, the differences between enum class and enum don't really have any relation, since they're introduced separately and enum class is a replacement for enum
13:10
@Puppy enums in C++ are shit as well
'cuz no methods/operators, etc
also where is my enum struct?
it's not "enum but it's a random special case of enums"
@Puppy laffo
anyways, C++ is a bad language. you can't take that piece of crap called "the C language", pour some honey on it and say that now it's tasty
because no matter what you add to it - it's still the same crap
It's just Puppy being cryptic again
user1804599
s/cryptic/an oblivious moron/
13:16
is this guaranteed to print '42 44' or is it UB or unspecified? coliru.stacked-crooked.com/a/19965bb00de9a81a
user1804599
No idea. Probably UB.
user1804599
> When a pointer or reference to object of type T1 is reinterpret_cast (or C-style cast) to a pointer or reference to object of a different type T2, the cast always succeeds, but the resulting pointer or reference may only be accessed if both T1 and T2 are standard-layout types and one of the following is true:
also a case of this
2 days ago, by sehe
Maybe you should try harder to not disguise the good arguments you have as a senseless rant.
user1804599
> T2 is a (possibly cv-qualified) base class of the dynamic type of the object
user1804599
13:18
Yeah seems to be fine.
@rightfold I wasn't really referring to the casting stuff
@rightfold more about constructing two objects in the same place, and manually filling in the base class
user1804599
oh then I don't know
user1804599
ask on Stack Overflow and farm kiloreps.
muh internet points
@orlp Completely illegal.
13:20
@Puppy why?
@orlp I think it's not guaranteed that Base will occupy first bytes of Derived
@Abyx it must
well, for one, you're making an assumption about where Base lives in the memory layout of Derived.
@orlp no, why?
@orlp No, it definitely does not have to at all.
13:21
@orlp Probably only for standard layout
the implementation can lay out base classes wherever it pleases.
otherwise you couldn't downcast pointers from Derived* to Base*
That's upcast and also it doesn't have to be a noop
@orlp it uses static_cast so it's fine
@orlp You can just use a non-zero offset... how do you think it works if you inherit from multiple bases?
13:22
remember, Derived* -> void* -> Base* is a legal course of action
no it certainly is not.
@orlp nope
it's like @Puppy said, think of multiple bases
how could this possibly work if Derived had more than one Base?
@orlp Only back to original type
you're saying that there should be several bases that should all occupy the same memory space, which is obviously totally impossible.
13:23
ah right
furthermore
you constructed the Base object twice.
@Puppy that's not illegal
@Puppy but it's POD
let me change the example a bit
hmm
13:24
basically it's int x; new(&x) int();
for this specific base you could probably get away with it, yes.
but in the general case, it would be illegal.
actually
hrm, I do assume in my codebase that the base class comes first in memory
... i think?
or maybe not
well it seems to me like you're trying to hack on a bunch of stuff to the C++ object model without a proper understanding or implementation of it.
not really
either don't implement it literally in terms of C++ classes, or emit actual code that corresponds to the C++ object model.
13:26
document all assumptions with static_assert
@milleniumbug in cases like that that's useless
what you need is language_lawyer_assert
or a DeathStation 9001
shutil.copy2()
dat naming
badlets everywhere
user1804599
@milleniumbug shutil is awesome.
was referring to the "copy2"
user1804599
Yeah should've been a Boolean parameter.
13:40
Ok, this is safe and defined, right? coliru.stacked-crooked.com/a/8ff826b8ee337eb4
it only ever goes from void* directly to either Base* or Derived*
why would that be any more defined than your previous example?
you've still assumed that Base is at offset 0.
because I don't assume anything about layouts?
no?
well
b and d are unrelated in this example
they just happen to be at the same location
I don't expect b to mean anything anymore when d gets constructed
I guess that if you never access any members of Base through b after Derived is constructed
however I still don't see why you would even want to do such a thing
13:46
to get a valid state object in a certain memory location regardless if the API user properly initializes its own object in the same location later
no wait
you could still be in violation of strict aliasing.
depends on exactly how it's worded by Standard
but you have a Base pointer that (may) not refer to any Base object or a Base subobject of a Derived object.
which could be in violation of strict aliasing.
@orlp Why not just make it mandatory for the API user to initialize it first?
user1804599
I am confuse.
@Puppy because if the user forgets then everything breaks
@Puppy does this not violate strict aliasing? coliru.stacked-crooked.com/a/1cd91ec78cfa0059
@milleniumbug hmm?
@orlp When you call new Derived you will implicitly invoke Base() ctor too, which will leave i indeterminate (which means you many not depend on it)
@sehe no it will not leave i indeterminate
it will put it to 42
13:50
For the rest I think it's not gonna crap out due to stdlayout sruct
@orlp it won't. Where does it?
@sehe in the Base constructor
@sehe Related to this
@sehe we're long past that
Oh. nm
Oh. That made things much clearer. So, it's just about reusing the memory without free
sort of
Well. That will always work for trivially destructibles.
it's about getting a certain memory location in a valid object state, regardless of what the user does afterwards
@orlp Then don't allow them to forget.
13:52
No need to have the base/derived relation AFAICT
either way, I'm fucked, because somewhere else I assume stuff about memory layout
user1804599
% for f in test/testdata/**/*.millm; echo 'foreignSubs: []' >> $f
user1804599
I <3 Z shell.
offsetof and static_assert
think I'll just switch to member, rather than inheritance
13:53
@orlp I think you can save yourself from the aliasing by setting it to null, since aliasing is about pointer values.
user1804599
@sehe offsetof is UB when used on non-standard layout types, but non-empty classes with non-empty bases are not standard layout.
user1804599
Where empty means "has no NSDMs".
@orlp that's nearly always simpler. Have you ever looked at Boost Intrusives implementation? Sound similar
Wow. I didn't realize that using #Boost #Intrusive would under the hood pull nasty ABI-specific tricks like that o.O http://www.boost.org/doc/libs/1_57_0/boost/intrusive/detail/parent_from_member.hpp
@rightfold which is why static_assert, derp?
hrm
if I have void* p = blabla, is then (new (p) A()) == static_cast<A*>(p) guaranteed to be true?
(only caring about pointer values)
(obviously one initializes and the other doesn't)
is there a link equivalent to -isystem? i looked at the doc page for linking flags for gcc and didnt see anything
14:04
Fuuuuuuu
Why can't I read
@Borgleader What would it do
well I'm fucked
guess I'll go check out that intrusive link
wait, can't even use that =/
@CatPlusPlus give the folder the same priority as system ones when looking for stuff to link with (as opposed to including headers) ?
Uh what priority
Xeo
Xeo
@Borgleader There's priority? I thought -isystem is just to ignore warnings n shit
14:07
-isystem mostly exists to silence warnings from vendor headers
> -isystem dir
Search dir for header files, after all directories specified by -I but before the standard system directories. Mark it as a system directory, so that it gets the same special treatment as is applied to the standard system directories. If dir begins with =, then the = will be replaced by the sysroot prefix; see --sysroot and -isysroot.
That treatment is no warnings
ah
so I can just use -L then?
good
thanks
14:10
morning
@sehe basically what I'm trying to do is store GC information intrusively inside some objects I use for my lisp implementation, but I need memory layout guarantees in order to be able to retrieve that info
@Prismatic moaning
@orlp struct heap_object { object* o; info i; };?
@Puppy could you elaborate?
sure
Ell
Ell
14:17
Tennis is the best sport to watch
what I'm saying is, why the fuck does this involve a bunch of shitting around with internal memory layouts?
just ask the compiler to lay out the information you need like a normal object.
because I'm writing a compacting GC allocator?
... so?
and there's multiple objects of different sizes?
that need to be tagged as such?
so I need to store the tag intrusively?
well, no.
you can just point to the heap_object instead if you need the info as well as the object.
"I need it" does not equate to "I need it intrusively"
14:20
I need it intrusively, because the object needs to know its own type too
.. why?
because it could be one of multiple types? Cons, Int, String, etc
so what?
refer to heap_object, you got info right there, job done.
user1804599
could you visualize how it would look on the heap? what I'm looking for (if I is info and O is object data) is IOOIOOOIOIOOOOOIO, and at every I you know how many bytes to skip to the next object
user1804599
14:23
Is that like run length encoding?
no
just unfortunate that I looks like 1
those are I's and O's
user1804599
Yes, I know.
@orlp Why would you need to start skipping bytes at every I? Or indeed, allocating I and O together at all?
user1804599
But there are more Os than Is.
just store the relevant pointers directly.
14:24
Also you can tag pointers
@Puppy storing pointers? why?
that would double my memory usage
With x64 you have 3 bits to play with
well, a 32bit pointer is the same as a 32bit offset
user1804599
@milleniumbug IIRC Ruby used to do that.
3 bits is not enough to store a size of anything
14:24
and then you can just go directly to whatever object you need to reference
I literally have one byte of data I want to associate with an object
user1804599
Store it at the beginning of the object.
If I could control memory layout I could do that
I can't
user1804599
Why not?
because apparently C++ has no fucking guarantees on memory layout
14:25
Then don't piggyback on C++
user1804599
Don't use C++ structs.
Provide one
user1804599
Use what I proposed when I showed you the collecting GC code example.
well, of course it doesn't, because what you're doing is silly ;p
@rightfold that would make all code INCREDIBLY painful
user1804599
14:26
You create type descriptor which store a list of fields and their offsets.
like, the entire implementation
user1804599
Write template functions which set and read fields.
user1804599
It's really easy and not painful at all.
hang on.
@rightfold what you did is just as much UB as what I'm doing
14:26
this is stupid.
Or don't manipulate the fields from inside the VM, write Lisp code for that :v
you're saying that you only store 1 byte of information?
user1804599
I implemented it and it was like twenty lines of code including automatic unboxing optimisation.
to determine the type?
@Puppy I'm saying I want to associate only one byte of information with an object, and both the object and the heap need to be able to access the information
14:27
uh huh.
Also "OMAHGERD I CAN'T WASTE MEMORY"
user1804599
Also, it was not UB.
except what I'm noticing here is that there's no way that 1 byte would possibly be enough.
user1804599
It used memcpy.
user1804599
There were no aliasing issues and everything was totally fine.
14:27
so I'm wondering what possible use you intend to put this 1 byte to.
user1804599
That was because I treated the GC heap as just a bunch of bytes, not reinterpret_casting to C++ structs.
@Puppy I have maximum 16 types, so 4 bits, then 1 bit for marking, 1 bit for GC protection = 6 bits
@orlp So... you know all the types in advance?
@Puppy yes
then why on earth are you even bothering with this dynamic layout crap?
user1804599
14:28
T value;
std::memcpy(&value, reinterpret_cast<char*>(objptr) + field.offset, field.size);
just make them all distinct C++ structs with the info in statically.
@Puppy because not all types have the same size?
user1804599
This is the gist of the function which reads a field from an object.
user1804599
You can assert(sizeof(T) == field.size); etc.
@orlp That doesn't mean they need dynamic layouts, since you know all the types in advance.
14:29
@Puppy but how will the heap extract this size information?
the heap needs to know how large each object is
in order to be able to iterate over all objects in the heap
@orlp Just put it in the static C++ predefined type.
whatever
that
is what I do right now
okeydokey
then what's the problem?
14:31
but it assumes that char is at the front of the Cons in memory
that problem can be remedied.
user1804599
@orlp Seriously. Start with this: gist.github.com/rightfold/a4122970bb4587d3bd01, and add a ctor to struct type which computes sizes and offsets.
Introduce one more base class
Don't use base classes at all
and assign in the CRTP class constructor to size
14:32
@milleniumbug Construct with it, but yes.
user1804599
Make the object header a pointer to the instance of struct type.
user1804599
Then you know the size of the object and its alignment requirements.
simply hold GCObjectBase* pointers.
then the compiler already does the offsetting for you and you don't need to give a shit about the memory layout.
user1804599
It's really simple if you forget about mapping between GC'd structures and C++ structures.
@rightfold It's quite simple this way as well, it's just that he really wants to optimize his memory use for some reason that makes it awkward.
ignoring alignment, aliasing, etc
user1804599
Compaction can loop over the fields and reassign them easily.
just pure memory layout
hmm
you're writing a compacting GC anyway, right?
14:35
yes
user1804599
And it's all completely safe. There's no UB at all.
then fuck sweeping over the dead objects.
just sweep the live objects into the new heap.
you don't need to iterate over the whole contents of the heap.
What's not alive is dead
@Puppy then how will I call destructors?
@orlp You're writing a GC. Fuck destructors. Allocate the memory you need on the GC and let the GC cycle handle it.
14:37
Ignore em
Why is it that cplusplus.com's results always come up first on google
Because it's ancient
@orlp Think why GC'd languages don't have destructors
also
And there were no alternatives for a long time so it has lots of inbound links
user1804599
14:37
@milleniumbug you mean destructures.
@milleniumbug Beh, most GC have dtors
then I need to write some fucking compliant allocators in order to use std::map n shit =/
you could simply change the heap to be an array of boost::variant<Cons, Nil, Int, ...> (more-or-less).
@rightfold Sure
@orlp It's pretty trivial to do in C++11- the new minimal allocator interface is quite fine.
user1804599
14:38
The only widely used GC'ed language I know of which does not offer finalizers is JavaScript and that's because it is being designed by utter morons (it even lacks weak references).
I don't want to write a general GC, just for my little objects =/
user1804599
Rationale: makes program non-deterministic.
@rightfold So do hash-tables and rand()
@orlp You could also use a variant instead.
and the cool thing of this implementation is that I could add other types at runtime through an API =/
14:40
well you really can't because you don't have enough space.
all a user had to do was inherit from Object*
you set a terrifically small pre-determined amount of space for determining types.
(assuming the memory layout was guaranteed)
the user can't really go adding types at all.
well, I said I only need 1 byte
In reality I'm using 8 or 4 depending on alignment
user1804599
14:40
With only 1 byte you can only have 256 types.
You only need 1 type tag for user types :v
@orlp Then fuck the byte and use a pointer (like, say, a vtable pointer).
@Puppy vtable pointer solves nothing only a part
the type information is per-class
the 'marked' and 'in use' tags for the GC are per-object
Use pools to store vtables :P
user1804599
Here's another nice compacting GC implementation, btw: raw.githubusercontent.com/dotnet/coreclr/master/src/gc/gc.cpp
user1804599
14:42
It's only a few lines of code and really simple.
user1804599
You can look at that.
lol
well then
don't put the fields in a struct, simply allocate them sequentially and then you know the layout.
that's what rightfold suggested
14:43
what was the problem with that?
still doesn't allow me to use std::string and co =/
why not?
hrm, actually, why not
user1804599
@orlp Did you open the Gist example I gave you?
there is no obvious reason why not.
14:44
@rightfold yes, yesterday
user1804599
No, the one I linked today.
it's clear that the additional fields could include a destruction function indirected through a means of your choice.
the 13000 line one?
user1804599
No, that wasn't Gist.
so simply allocate the fields sequentially in the order and layout of your choosing
and then job done.
any info you need to do whatever op you need can go in the info fields.
user1804599
14:45
13 mins ago, by rightfold
@orlp Seriously. Start with this: https://gist.github.com/rightfold/a4122970bb4587d3bd01, and add a ctor to struct type which computes sizes and offsets.
user1804599
In that example, add an std::function to struct type which moves the object from location A to location B.
static_assert(std::is_pod<T>());
user1804599
Then your std::string wrapper would have no fields, of course.
how will that work with std::string?
user1804599
Don't make the string a field.
user1804599
14:46
Fields should only be pointers to other objects.
......, that only adds more allocations
so basically, he's back to the "Don't destruct shit, put everything on the GC" solution.
I'm trying to solve allocating here - not generate more
it's a compacting GC, allocations are pretty cheap if not free.
user1804599
@orlp ugh
user1804599
14:47
ok let's start over
look, there's more than one solution here with various drawbacks, just pick the one that gives you the most things you like.
user1804599
Fields should only be pointers to other objects, where "object" means "lisp object", not "C++ object".
20 mins ago, by milleniumbug
Also "OMAHGERD I CAN'T WASTE MEMORY"
@rightfold what about actual data
like strings, integers, etc
user1804599
Don't make them fields.
user1804599
14:48
refresh the gist, I added a field to struct type: gist.github.com/rightfold/a4122970bb4587d3bd01
user1804599
Set size to the size of std::string plus the size you need to the vptr and the padding.
user1804599
Set move to a function which moves an std::string.
Tag pointers. With 3 bits you can choose between 0 -> pointer to object, 1 -> integer, 2 -> string data, 3 -> more stuff
user1804599
// And no, overlapping is _not_ a problem:
std::string a(std::move(original));
*target = std::move(a);
@rightfold I know that
I'm doing a copy now which works fine
14:49
@milleniumbug You really love messing with pointer tags don't you
user1804599
Problem solved!
user1804599
@orlp Ok so let me give an example of memory layout of various objects.
@CatPlusPlus Nice size optimization for everyone :D
Ell
Ell
Holy Jesus
Did anyone see that rally?
no
14:52
No
@Ell raises arm Present!
@Ell what rally?
wait I have it
rallies in Bristol are not uncommon
14:53
I have the fucking solution
usually around "We want human rights", "No more austerity", or one I saw on Wendesday about "Cameron Eats Puppies"
@orlp You mean, other than the ones already presented?
Ell
Ell
Tennis rally
or the ones you rejected out of hand because of excessive memory use (lol)
Ell
Ell
Maybe rally is wrong word
well, those used more memory, yes
14:55
I'm pretty sure the one about just allocating the fields in the order you want doesn't use any more memory.
man... how could calling erase() on a map cause it to seg fault
ugh
if you have already deleted it
easily
user1804599
Assuming std::string is fine with alignment of 8 bytes.
14:58
its because I forgot the custom comparator
Man this is such an annoying fucking pattern its happened so many times

« first day (1730 days earlier)      last day (3443 days later) »