From 18d5cfdb858cf32ca14a714c9eeb4032683a685b Mon Sep 17 00:00:00 2001 From: pengwa Date: Fri, 25 Aug 2023 00:40:40 +0800 Subject: [PATCH] =?UTF-8?q?Fix=20build=20-=20redefinition=20of=20default?= =?UTF-8?q?=20argument=20for=20=E2=80=98long=20unsigned=20int=20Extent?= =?UTF-8?q?=E2=80=99=20(#17281)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### Fix build - redefinition of default argument for ‘long unsigned int Extent’ One of the training customer env, building ORT, there is such a build error. The GCC version are ``` aiscuser@node-0:/tmp/onnxruntime$ gcc --version gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0 aiscuser@node-0:/tmp/onnxruntime$ g++ --version g++ (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0 ``` But on our dev node using same GCC/G++, we don't have build issue., not sure what's the difference but giving an explict type when creating `gsl::span` fixed the problem. ``` /tmp/onnxruntime/build/Linux/RelWithDebInfo/_deps/gsl-src/include/gsl/span:394:7: error: redefinition of default argument for ‘long unsigned int Extent’ 394 | class span | ^~~~ /tmp/onnxruntime/build/Linux/RelWithDebInfo/_deps/gsl-src/include/gsl/span_ext:46:51: note: original definition appeared here 46 | template | ^~~~~~~~~~~~~~~ /tmp/onnxruntime/include/onnxruntime/core/common/span_utils.h:82:93: error: return type ‘class gsl::span’ is incomplete 82 | [[nodiscard]] inline gsl::span AsByteSpan(const void* data, size_t length) { | ^ /tmp/onnxruntime/include/onnxruntime/core/common/span_utils.h: In function ‘void onnxruntime::AsByteSpan(const void*, size_t)’: /tmp/onnxruntime/include/onnxruntime/core/common/span_utils.h:83:68: error: class template argument deduction failed: 83 | return gsl::span(reinterpret_cast(data), length); | ^ /tmp/onnxruntime/include/onnxruntime/core/common/span_utils.h:83:68: error: no matching function for call to ‘span(const std::byte*, size_t&)’ /tmp/onnxruntime/build/Linux/RelWithDebInfo/_deps/gsl-src/include/gsl/span:740:1: note: candidate: ‘template gsl::span(Type (&)[Extent])-> gsl::span’ 740 | span(Type (&)[Extent]) -> span; | ^~~~ /tmp/onnxruntime/build/Linux/RelWithDebInfo/_deps/gsl-src/include/gsl/span:740:1: note: template argument deduction/substitution failed: /tmp/onnxruntime/include/onnxruntime/core/common/span_utils.h:83:68: note: mismatched types ‘Type [Extent]’ and ‘const std::byte*’ 83 | return gsl::span(reinterpret_cast(data), length); | ^ /tmp/onnxruntime/build/Linux/RelWithDebInfo/_deps/gsl-src/include/gsl/span:743:1: note: candidate: ‘template gsl::span(std::array<_Tp, _Nm>&)-> gsl::span’ 743 | span(std::array&) -> span; | ^~~~ /tmp/onnxruntime/build/Linux/RelWithDebInfo/_deps/gsl-src/include/gsl/span:743:1: note: template argument deduction/substitution failed: /tmp/onnxruntime/include/onnxruntime/core/common/span_utils.h:83:68: note: mismatched types ‘std::array<_Tp, _Nm>’ and ‘const std::byte*’ 83 | return gsl::span(reinterpret_cast(data), length); | ^ ``` ### Motivation and Context --- include/onnxruntime/core/common/span_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/onnxruntime/core/common/span_utils.h b/include/onnxruntime/core/common/span_utils.h index d447b55f55..b2d1aefee9 100644 --- a/include/onnxruntime/core/common/span_utils.h +++ b/include/onnxruntime/core/common/span_utils.h @@ -80,7 +80,7 @@ template } [[nodiscard]] inline gsl::span AsByteSpan(const void* data, size_t length) { - return gsl::span(reinterpret_cast(data), length); + return gsl::span(reinterpret_cast(data), length); } template