Skip to content
This repository was archived by the owner on May 9, 2024. It is now read-only.

Fixed ambiguous (from MSVC point of view) call #246

Merged

Conversation

gshimansky
Copy link
Contributor

On windows compiler complains that 4211000000 is ambiguous, on Linux gcc complains that 4211000000LL is ambiguous. I couldn't find a way to satisfy them both with the same code, hence use ifdef.

Copy link
Contributor

@kurapov-peter kurapov-peter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about static_cast<long long int>()?

@gshimansky
Copy link
Contributor Author

How about static_cast<long long int>()?

It is the same as writing 4211000000LL and gcc doesn't compile it:

[ 96%] Building CXX object omniscidb/Tests/CMakeFiles/QueryBuilderTest.dir/QueryBuilderTest.cpp.o
/nfs/site/home/gashiman/work/hdk/omniscidb/Tests/QueryBuilderTest.cpp: In member function 'virtual void QueryBuilderTest_CstExprScalar_Test::TestBody()':
/nfs/site/home/gashiman/work/hdk/omniscidb/Tests/QueryBuilderTest.cpp:1962:115: error: call of overloaded 'checkCst(hdk::ir::BuilderExpr, long long int, const hdk::ir::TimeType*)' is ambiguous
 1962 |   checkCst(builder.time("01:10:11"), static_cast<long long int>(4211000000), ctx().time64(TimeUnit::kMicro, false));
      |                                                                                                                   ^
/nfs/site/home/gashiman/work/hdk/omniscidb/Tests/QueryBuilderTest.cpp:195:6: note: candidate: 'void {anonymous}::checkCst(const hdk::ir::BuilderExpr&, int64_t, const hdk::ir::Type*)'
  195 | void checkCst(const BuilderExpr& expr, int64_t val, const Type* type) {
      |      ^~~~~~~~
/nfs/site/home/gashiman/work/hdk/omniscidb/Tests/QueryBuilderTest.cpp:203:6: note: candidate: 'void {anonymous}::checkCst(const hdk::ir::BuilderExpr&, int, const hdk::ir::Type*)'
  203 | void checkCst(const BuilderExpr& expr, int val, const Type* type) {
      |      ^~~~~~~~
/nfs/site/home/gashiman/work/hdk/omniscidb/Tests/QueryBuilderTest.cpp:214:6: note: candidate: 'void {anonymous}::checkCst(const hdk::ir::BuilderExpr&, double, const hdk::ir::Type*)'
  214 | void checkCst(const BuilderExpr& expr, double val, const Type* type) {
      |      ^~~~~~~~
/nfs/site/home/gashiman/work/hdk/omniscidb/Tests/QueryBuilderTest.cpp:225:6: note: candidate: 'void {anonymous}::checkCst(const hdk::ir::BuilderExpr&, bool, const hdk::ir::Type*)'
  225 | void checkCst(const BuilderExpr& expr, bool val, const Type* type) {
      |      ^~~~~~~~

@gshimansky
Copy link
Contributor Author

I found that static_cast<int64_t> (4211000000) satisfies both compilers.

@gshimansky gshimansky force-pushed the gregory/windows-ambiguous-call branch from e59307f to c919cd8 Compare March 6, 2023 18:45
@gshimansky gshimansky requested a review from kurapov-peter March 6, 2023 22:08
@kurapov-peter kurapov-peter merged commit b36646e into intel:main Mar 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants