|
Boost : |
Subject: Re: [boost] BOOST_NO_CXX11_CONSTEXPR and msvc-14.0
From: Stephan T. Lavavej (stl_at_[hidden])
Date: 2015-07-21 20:51:25
[Glen Fernandes]
> Only what was reported for the RC:
Was this reported on Connect? I didn't see any bug reports filed against the STL.
> 1. For x86 and x64: std::alignment_of<std::nullptr_t>::value is 1, yet
> compiler aligns at 4
> 2. For x86: std::alignment_of<T Class::*>::value is 4, yet compiler aligns at 8
> For x64: std::alignment_of<T Class::*>::value is 8, yet compiler aligns at 4
> 3. For x86: std::alignment_of<T (Class::*)()>::value is 4, yet
> compiler aligns at 8
> For x64: std::alignment_of<T (Class::*)()>::value is 8, yet
> compiler aligns at 4
I am observing discrepancies with nullptr_t on x86/x64 and PMDs on x64 only, but not with PMFs. I've filed DevDiv#1202506 "alignof reports inaccurate values" with the repro at the end of this mail.
If you can demonstrate x86 PMD failure, or x86/x64 PMF failure, I'll add that to the bug report.
> I haven't checked the RTM yet, but apparently VC12's std::alignment_of
> for the relevant types reported the same value that the compiler chose
> to align objects of those types.
Yeah, that's because 2013 used library-only tech, and 2015 uses alignof as required/depicted by the Standard.
Thanks,
STL
C:\Temp>type meow.cpp
#ifdef _MSC_VER
#pragma warning(disable: 4127) // conditional expression is constant
#endif
#include <stddef.h>
template <typename T> struct RemoveReference {
typedef T type;
};
template <typename T> struct RemoveReference<T&> {
typedef T type;
};
template <typename T> struct RemoveReference<T&&> {
typedef T type;
};
template <typename T> struct GetAlign {
T elem0;
char elem1;
T elem2;
};
template <typename T> struct AlignmentOf {
using U = typename RemoveReference<T>::type;
static const size_t value = sizeof(GetAlign<U>) - 2 * sizeof(U);
};
struct Meow { };
#include <cstddef>
#include <iostream>
using namespace std;
template <typename T> void print(const char * const name) {
cout << name << endl;
cout << "AlignmentOf<T>::value = " << AlignmentOf<T>::value << endl;
cout << " alignof(T) = " << alignof(T);
if (AlignmentOf<T>::value != alignof(T)) {
cout << " <== FAIL";
}
cout << endl << endl;
}
#define PRINT(X) print<X>(#X)
int main() {
PRINT(char);
PRINT(short);
PRINT(int);
PRINT(long);
PRINT(long long);
PRINT(float);
PRINT(double);
PRINT(int *);
using PMD = int Meow::*;
using PMF = int (Meow::*)(int);
PRINT(nullptr_t);
PRINT(PMD);
PRINT(PMF);
}
[x86]
C:\Temp>cl /EHsc /nologo /W4 /MTd meow.cpp
meow.cpp
C:\Temp>meow
char
AlignmentOf<T>::value = 1
alignof(T) = 1
short
AlignmentOf<T>::value = 2
alignof(T) = 2
int
AlignmentOf<T>::value = 4
alignof(T) = 4
long
AlignmentOf<T>::value = 4
alignof(T) = 4
long long
AlignmentOf<T>::value = 8
alignof(T) = 8
float
AlignmentOf<T>::value = 4
alignof(T) = 4
double
AlignmentOf<T>::value = 8
alignof(T) = 8
int *
AlignmentOf<T>::value = 4
alignof(T) = 4
nullptr_t
AlignmentOf<T>::value = 4
alignof(T) = 1 <== FAIL
PMD
AlignmentOf<T>::value = 4
alignof(T) = 4
PMF
AlignmentOf<T>::value = 4
alignof(T) = 4
[x64]
C:\Temp>cl /EHsc /nologo /W4 /MTd meow.cpp
meow.cpp
C:\Temp>meow
char
AlignmentOf<T>::value = 1
alignof(T) = 1
short
AlignmentOf<T>::value = 2
alignof(T) = 2
int
AlignmentOf<T>::value = 4
alignof(T) = 4
long
AlignmentOf<T>::value = 4
alignof(T) = 4
long long
AlignmentOf<T>::value = 8
alignof(T) = 8
float
AlignmentOf<T>::value = 4
alignof(T) = 4
double
AlignmentOf<T>::value = 8
alignof(T) = 8
int *
AlignmentOf<T>::value = 8
alignof(T) = 8
nullptr_t
AlignmentOf<T>::value = 8
alignof(T) = 1 <== FAIL
PMD
AlignmentOf<T>::value = 4
alignof(T) = 8 <== FAIL
PMF
AlignmentOf<T>::value = 8
alignof(T) = 8
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk