Emacs internals: Tagged pointers vs. C++ std:variant and LLVM (Part 3)
thecloudlet.github.io
Emacs internals: Tagged pointers vs. C++ std:variant and LLVM (Part 3)
1–10 of 39 posts
Re: Emacs internals: Tagged pointers vs. C++ std:variant and LLVM (Part 3)
#2Re: Emacs internals: Tagged pointers vs. C++ std:variant and LLVM (Part 3)
#3I had thought you need the pointer-sized integer types and mustn't do this directly to an actual pointer, but maybe I was wrong (in theory, obviously practice doesn't follow but that's a dangerous game)
Re: Emacs internals: Tagged pointers vs. C++ std:variant and LLVM (Part 3)
#4It's not clear to me (and as an unsafe language it's not called out by your compiler if you do something illegal) what the correct way to spell this kind of trick is in C++ I had thought you need the pointer-sized integer types and mustn't do this directly to an actual pointer, but maybe I was wrong (in theory, obviously practice doesn't follow but that's a dangerous game)
Re: Emacs internals: Tagged pointers vs. C++ std:variant and LLVM (Part 3)
#5Re: Emacs internals: Tagged pointers vs. C++ std:variant and LLVM (Part 3)
#6It's not clear to me (and as an unsafe language it's not called out by your compiler if you do something illegal) what the correct way to spell this kind of trick is in C++ I had thought you need the pointer-sized integer types and mustn't do this directly to an actual pointer, but maybe I was wrong (in theory, obviously practice doesn't follow but that's a dangerous game)
In modern C++, the technically "correct" and safe way to spell this trick is exactly as you suggested: using uintptr_t (or intptr_t).
Re: Emacs internals: Tagged pointers vs. C++ std:variant and LLVM (Part 3)
#7It's not clear to me (and as an unsafe language it's not called out by your compiler if you do something illegal) what the correct way to spell this kind of trick is in C++ I had thought you need the pointer-sized integer types and mustn't do this directly to an actual pointer, but maybe I was wrong (in theory, obviously practice doesn't follow but that's a dangerous game)
Doing bitwise operations directly on raw pointers is a fast track to Undefined Behavior in standard C/C++. Emacs gets away with it largely due to its age, its heavy reliance on specific GCC behaviors/extensions, and how its build system configures compiler optimizations. In modern C++, the technically "correct" and safe way to spell this trick is exactly as you suggested: using uintptr_t (or intptr_t).
Re: Emacs internals: Tagged pointers vs. C++ std:variant and LLVM (Part 3)
#8It's not clear to me (and as an unsafe language it's not called out by your compiler if you do something illegal) what the correct way to spell this kind of trick is in C++ I had thought you need the pointer-sized integer types and mustn't do this directly to an actual pointer, but maybe I was wrong (in theory, obviously practice doesn't follow but that's a dangerous game)
Doing bitwise operations directly on raw pointers is a fast track to Undefined Behavior in standard C/C++. Emacs gets away with it largely due to its age, its heavy reliance on specific GCC behaviors/extensions, and how its build system configures compiler optimizations. In modern C++, the technically "correct" and safe way to spell this trick is exactly as you suggested: using uintptr_t (or intptr_t).
Re: Emacs internals: Tagged pointers vs. C++ std:variant and LLVM (Part 3)
#9Earlier quoted context omitted.
Doing bitwise operations directly on raw pointers is a fast track to Undefined Behavior in standard C/C++. Emacs gets away with it largely due to its age, its heavy reliance on specific GCC behaviors/extensions, and how its build system configures compiler optimizations. In modern C++, the technically "correct" and safe way to spell this trick is exactly as you suggested: using uintptr_t (or intptr_t).
Is there a similar solution to doing this in Rust? I suppose inside `unsafe` you can do basically anything.
Re: Emacs internals: Tagged pointers vs. C++ std:variant and LLVM (Part 3)
#10Earlier quoted context omitted.
Doing bitwise operations directly on raw pointers is a fast track to Undefined Behavior in standard C/C++. Emacs gets away with it largely due to its age, its heavy reliance on specific GCC behaviors/extensions, and how its build system configures compiler optimizations. In modern C++, the technically "correct" and safe way to spell this trick is exactly as you suggested: using uintptr_t (or intptr_t).
Is there a similar solution to doing this in Rust? I suppose inside `unsafe` you can do basically anything.