F
Fedor Rodikov
Hi Group!
Recently I met a problem in a legacy C++ project. This project has
more than one translation unit which include header with class
template X.
This #include directive enclosed by #paragma pack in each cpp and the
value of this packing not the same. Does the X violate ODR or not?
Could a different packing in different translation units leads to UB?
For example:
// x.h
template< typename >
struct X { ... };
// a.cpp
#pragma pack( push )
#pragma pack( 1 )
#include "x.h"
#pragma pack( pop )
....
// b.cpp
#pragma pack( push )
#pragma pack( 8 )
#include "x.h"
#pragma pack( pop )
....
Thanks in advance!
Recently I met a problem in a legacy C++ project. This project has
more than one translation unit which include header with class
template X.
This #include directive enclosed by #paragma pack in each cpp and the
value of this packing not the same. Does the X violate ODR or not?
Could a different packing in different translation units leads to UB?
For example:
// x.h
template< typename >
struct X { ... };
// a.cpp
#pragma pack( push )
#pragma pack( 1 )
#include "x.h"
#pragma pack( pop )
....
// b.cpp
#pragma pack( push )
#pragma pack( 8 )
#include "x.h"
#pragma pack( pop )
....
Thanks in advance!