dmlc / xgboost

Scalable, Portable and Distributed Gradient Boosting (GBDT, GBRT or GBM) Library, for Python, R, Java, Scala, C++ and more. Runs on single machine, Hadoop, Spark, Dask, Flink and DataFlow
https://xgboost.readthedocs.io/en/stable/
Apache License 2.0
26.14k stars 8.71k forks source link

[MSVC][permissive-] xgboost failed to build with error C3779 under /permissive- on MSVC #7795

Open xiaoxiao-Xu opened 2 years ago

xiaoxiao-Xu commented 2 years ago

Hi all, The MSVC team recently added xgboost as part of RWC testing. But we found error C3779 when building xgboost with '/permissive-'. Could you please take a quick look at the issue? Thanks in advance.

Repro steps:

  1. git clone https://github.com/dmlc/xgboost.git F:\gitP\dmlc\xgboost
  2. cd F:\gitP\dmlc\xgboost & mkdir build_amd64
  3. set CL= /permissive-
  4. cd F:\gitP\dmlc\xgboost\build_amd64
  5. cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_SYSTEM_VERSION=10.0.18362.0 -DGOOGLE_TEST=ON -DUSE_DMLC_GTEST=ON ..
  6. msbuild /m /p:Platform=x64 /p:Configuration=Release xgboost.sln /t:Rebuild

Expected Behavior xgboost could build successfully with '/permissive-'.

Actual Behavior build.log

test_regen.cc F:\gitP\dmlc\xgboost\tests\cpp\tree\test_regen.cc(69,30): error C3779: 'xgboost::anonymous-namespace'::RegenTest::Iter': a function that returns 'auto' cannot be used before it is defined F:\gitP\dmlc\xgboost\tests\cpp\tree\test_regen.cc(60): note: see declaration of 'xgboost::anonymous-namespace'::RegenTest::Iter' F:\gitP\dmlc\xgboost\tests\cpp\tree\test_regen.cc(63,10): note: This diagnostic occurred in the compiler generated function 'size_t xgboost::`anonymous-namespace'::RegenTest::TestTreeMethod(std::string,std::string,bool) const'

trivialfis commented 2 years ago

I don't currently have a windows machine at hand, would you like to submit a fix?

xiaoxiao-Xu commented 2 years ago

@trivialfis No. We recently failed to build xgboost with '/permissive-'. So, I reported a new issue here.

hcho3 commented 2 years ago

@xiaoxiao-Xu Thank you for reporting this issue. We provide a pre-compiled binary for our Windows users, and we do not enable /permissive- flag in our build pipeline. Thus, this issue does not directly affect our users, and we will not prioritize this issue for a while. Thanks for your understanding.

xiaoxiao-Xu commented 2 years ago

Ok. Thanks for your first look. If the issue was fixed, please let me know.

QuellaZhang commented 2 years ago

New errors detected under /permissive- and /std:c++latest.

F:\gitP\dmlc\xgboost\tests\cpp\data\test_sparse_page_dmatrix.cc(93,75): error C2039: 'value': is not a member of 'std' [F:\gitP\dmlc\xgboost\build_amd64\testxgboost.vcxproj] F:\gitP\dmlc\xgboost\tests\cpp\tree\test_regen.cc(69,30): error C3779: 'xgboost::anonymous-namespace'::RegenTest::Iter': a function that returns 'auto' cannot be used before it is defined [F:\gitP\dmlc\xgboost\build_amd64\testxgboost.vcxproj]