[CXX-659] max_align_t not a part of std namespace in GCC 4.8.3, thus master build is failing Created: 31/Aug/15  Updated: 02/Sep/15  Resolved: 02/Sep/15

Status: Closed
Project: C++ Driver
Component/s: Build
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Trivial - P5
Reporter: Otto Cruz Assignee: Andrew Morrow (Inactive)
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Not sure what the policy is for reporting issues on the in-progress (master) branch, but...

According to gnu, max_align_t wasn't added to std namespace until gcc 4.9.x. (Reference: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56019)

Removing std namespace on max_align_t allows it to compile again in my Centos7 VM.

Note, this doesn't seem to be an issue for Mac OS X 10.10.4 with Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn).

Thanks!

Reference:
[ 91%] Building CXX object src/mongocxx/test/CMakeFiles/test_driver.dir/pool.cpp.o
/home/ocruz/mongodb/mongo-cxx-driver/src/mongocxx/test/pool.cpp: In function ‘void ____C_A_T_C_H____T_E_S_T____127()’:
/home/ocruz/mongodb/mongo-cxx-driver/src/mongocxx/test/pool.cpp:130:5: error: ‘max_align_t’ is not a member of ‘std’
std::max_align_t dummy_address;
^
/home/ocruz/mongodb/mongo-cxx-driver/src/mongocxx/test/pool.cpp:130:5: note: suggested alternative:
In file included from /usr/include/c++/4.8.2/cstddef:42:0,
from /home/ocruz/mongodb/mongo-cxx-driver/src/third_party/catch/include/catch.hpp:785,
from /home/ocruz/mongodb/mongo-cxx-driver/src/mongocxx/test/pool.cpp:15:
/usr/lib/gcc/x86_64-redhat-linux/4.8.3/include/stddef.h:425:3: note: ‘max_align_t’
} max_align_t;
^
/home/ocruz/mongodb/mongo-cxx-driver/src/mongocxx/test/pool.cpp:130:22: error: expected ‘;’ before ‘dummy_address’
std::max_align_t dummy_address;
^
/home/ocruz/mongodb/mongo-cxx-driver/src/mongocxx/test/pool.cpp:133:65: error: ‘dummy_address’ was not declared in this scope
mongoc_client_t* fake = reinterpret_cast<mongoc_client_t*>(&dummy_address);
^
make[2]: *** [src/mongocxx/test/CMakeFiles/test_driver.dir/pool.cpp.o] Error 1
make[1]: *** [src/mongocxx/test/CMakeFiles/test_driver.dir/all] Error 2
make: *** [all] Error 2



 Comments   
Comment by Andrew Morrow (Inactive) [ 02/Sep/15 ]

ocruz - Thanks for pointing that out on the wiki. I've updated it.

Also, I believe that the use of std::max_align_t is confined to the tests. So you might be able to get away with GCC 4.8 as long as you only build the install target? I realize you probably want to run the tests though. Another option might be to #ifdef out that part of the test on GCC < 4.9? I'm less averse to some tweaks like that, but what I'd like to avoid is having to start doing the 'stdx' trick for max_align_t globally. If you find a compromise solution that seems reasonable feel free to send us a PR and we will give it a look.

I'm going to close this ticket for now, but feel free to re-open it if you have a suggestion for a fix and want us to evaluate.

Thanks for trying out the new driver!

Comment by Otto Cruz [ 02/Sep/15 ]

Makes total sense, Andrew. I'll deal with this on my side.

Though if someone could update the quick-start guide for the c++11 driver on github to reflect g++ 4.9+ instead of 4.8+, to hopefully help others.

Thanks for the input!

Comment by Andrew Morrow (Inactive) [ 02/Sep/15 ]

Hi Otto -

Thanks for the bug report. One of the design goals of the new C++11 driver was to write to the C++11 standard and not add compatibility hacks to accommodate compilers that have not yet reached conformance. This means that GCC 4.9 is most likely the minimum acceptable GCC version for building the C++11 driver. I'd recommend either building with clang, or using a newer GCC.

Thanks,
Andrew

Generated at Wed Feb 07 21:59:53 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.