Compiling in C++20 mode

Yuriy Skalko yuriy.skalko at gmail.com
Tue Dec 29 09:28:26 UTC 2020


> Thanks for working on this, Yuriy! I'm not sure if the following is
> helpful, but curent master fails for me with GCC and Clang with C++20 on
> Ubuntu 20.10. Here are details in case you or anyone else is motivated
> to take a look:
> 
> /home/vbox/lyxbuilds/master-clang/repo/src/mathed/MathParser.cpp:373:21: error: 
> use of deleted function ‘std::basic_ostream<char, _Traits>& 
> std::operator<<(std::basic_ostream<char, _Traits>&, wchar_t) [with _Traits = 
> std::char_traits<char>]’
>   373 |   os << t.character();
> 
> Clang gives the following:
> 
> [ 72%] Building CXX object src/mathed/CMakeFiles/mathed.dir/MathParser.cpp.o    
>                                                                                 
>                                                    
> cd /home/vbox/lyxbuilds/master-clang/CMakeBuild/src/mathed && /usr/bin/clang++  
> -DBOOST_USER_CONFIG="<config.h>" -DHUNSPELL_STATIC -DQT_CORE_LIB 
> -I/home/vbox/lyxbuilds/master-clang/CMakeBuild -I/home/vbox/lyxbui
> lds/master-clang/repo/src -I/usr/include/enchant-2 
> -I/home/vbox/lyxbuilds/master-clang/repo/3rdparty/hunspell/1.7.0/src/hunspell 
> -I/home/vbox/lyxbuilds/master-clang/repo/3rdparty/hunspell/1.7.0/src 
> -I/home/vbox/lyxbuilds/master-clang/repo/3rdparty/boost 
> -I/home/vbox/lyxbuilds/master-clang/repo/3rdparty/nod 
> -I/home/vbox/lyxbuilds/master-clang/repo/src/mathed -isystem 
> /usr/include/x86_64-linux-gnu/qt5 -isystem /usr/inclu
> de/x86_64-linux-gnu/qt5/QtCore -isystem 
> /usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++  -Wall -Wextra 
> -Wno-deprecated-copy --std=c++20 -Wno-deprecated-register -DENABLE_ASSERTIONS=1 
> -D_GLIBCXX_DEBUG -D_GLIBCXX_
> DEBUG_PEDANTIC -fno-strict-aliasing  -O0 -g3 -D_DEBUG   -Werror -fPIC 
> -std=c++2a -o CMakeFiles/mathed.dir/MathParser.cpp.o -c 
> /home/vbox/lyxbuilds/master-clang/repo/src/mathed/MathParser.cpp                
>      
> /home/vbox/lyxbuilds/master-clang/repo/src/mathed/MathParser.cpp:373:6: error: 
> overload resolution selected deleted operator '<<'                              
>                                                                     os << 
> t.character();                                                                  
>                                                                                 
>                              
>                 ~~ ^  ~~~~~~~~~~~~~                                             
>                                                                                 
>                                                    
> $ g++ --version
> g++ (Ubuntu 10.2.0-13ubuntu1) 10.2.0
> Copyright (C) 2020 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions.  There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> 
> $ clang++ --version
> Ubuntu clang version 11.0.0-2
> Target: x86_64-pc-linux-gnu
> Thread model: posix
> InstalledDir: /usr/bin
> 
> Scott

Hi Scott,
Please try the attached patch. I'm not sure how this line compiled at 
all with earlier standards on Linux (where char_type is wchar_t). How 
wchar_t was outputted into char stream?


Yuriy

-------------- next part --------------
diff --git a/src/mathed/MathParser.cpp b/src/mathed/MathParser.cpp
index dd43dd9eac..8659b59576 100644
--- a/src/mathed/MathParser.cpp
+++ b/src/mathed/MathParser.cpp
@@ -370,9 +370,9 @@ ostream & operator<<(ostream & os, Token const & t)
 		os << '\\' << to_utf8(cs);
 	}
 	else if (t.cat() == catLetter)
-		os << t.character();
+		os << to_utf8(docstring(1, t.character()));
 	else
-		os << '[' << t.character() << ',' << t.cat() << ']';
+		os << '[' << to_utf8(docstring(1, t.character())) << ',' << t.cat() << ']';
 	return os;
 }
 


More information about the lyx-devel mailing list