Skip to content

Should STL support exotic MSVC pointers? #987

Description

It may sound surprising, but:

  • 32-bit pointers are available for 64-bit compilation, and vice versa
  • There are explicitly signed and unsinged pointers, and "normal" pointers behave as signed

STL does not support this feature fully. They work with is_pointer_v, but not with atomic.
Example:

#include <Windows.h>
#include <atomic>
#include <iostream>
#include <type_traits>

int main() {
    std::cout << std::is_pointer_v<int* POINTER_32> << '\n'; // prints 1
    std::cout << std::is_pointer_v<int* POINTER_64> << '\n'; // prints 1

    
    std::atomic<int* POINTER_32> sp32;
    sp32.fetch_add(1); // this does not compile on 64-bit

    std::atomic<int* POINTER_64> sp64;
    sp64.fetch_add(1); // this does not compile on 32-bit

}

Should they be supported fully by STL?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requestedresolvedSuccessfully resolved without a commit

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions