[LyX/master] Do not return copies of string members

Enrico Forestieri forenr at lyx.org
Wed May 10 21:19:16 UTC 2023


On Wed, May 10, 2023 at 11:21:04AM +0200, Jean-Marc Lasgouttes wrote:
> 
>Le 09/05/2023 à 22:08, Enrico Forestieri a écrit :
>>On Fri, May 05, 2023 at 07:28:59PM +0200, Jean-Marc Lasgouttes wrote:
>>>
>>>commit 3ae5d6bdec1df23cc0d848b2d8bf6b0932eeee3b
>>>Author: Jean-Marc Lasgouttes <lasgouttes at lyx.org>
>>>Date:   Fri May 5 20:35:23 2023 +0200
>>>
>>>   Do not return copies of string members
>>>
>>>   This fixes the g++ 12 warnings below.
>>
>>After this commit my cygwin build crashes badly at startup. I can't 
>>even get a backtrace. What is strange is that a native Windows build 
>>works fine, instead. Both builds use the same version of gcc:
>
>Strange... Did you try to run it under valgrind or something similar?

Unfortunately valgrind is not available on cygwin and I don't know of 
any other similar software.

>I do not see that. Valgrind output horrors (more on that later), but 
>not related to this. Did you check whether a full rebuild helps?

No, it does not. Simply reverting the commit solves the issue.
However I get a lot of warnings like the following:

In file included from ../../../../src/frontends/qt/Toolbars.cpp:15:
../../../../src/Converter.h: In member function ‘const string& lyx::Converter::from() const’:
../../../../src/Converter.h:55:51: warning: returning reference to temporary [-Wreturn-local-addr]
    55 |         std::string const & from() const { return from_; }
       |                                                   ^~~~~
../../../../src/Converter.h: In member function ‘const string& lyx::Converter::to() const’:
../../../../src/Converter.h:57:49: warning: returning reference to temporary [-Wreturn-local-addr]
    57 |         std::string const & to() const { return to_; }
       |                                                 ^~~
../../../../src/Converter.h: In member function ‘const string& lyx::Converter::command() const’:
../../../../src/Converter.h:59:54: warning: returning reference to temporary [-Wreturn-local-addr]
    59 |         std::string const & command() const { return command_; }
       |                                                      ^~~~~~~~
../../../../src/Converter.h: In member function ‘const string& lyx::Converter::flags() const’:
../../../../src/Converter.h:63:52: warning: returning reference to temporary [-Wreturn-local-addr]
    63 |         std::string const & flags() const { return flags_; }
       |                                                    ^~~~~~
../../../../src/Converter.h: In member function ‘const string& lyx::Converter::latex_flavor() const’:
../../../../src/Converter.h:77:59: warning: returning reference to temporary [-Wreturn-local-addr]
    77 |         std::string const & latex_flavor() const { return latex_flavor_; }
       |                                                           ^~~~~~~~~~~~~
../../../../src/Converter.h: In member function ‘const string& lyx::Converter::result_dir() const’:
../../../../src/Converter.h:87:57: warning: returning reference to temporary [-Wreturn-local-addr]
    87 |         std::string const & result_dir() const { return result_dir_; }
       |                                                         ^~~~~~~~~~~
../../../../src/Converter.h: In member function ‘const string& lyx::Converter::result_file() const’:
../../../../src/Converter.h:89:58: warning: returning reference to temporary [-Wreturn-local-addr]
    89 |         std::string const & result_file() const { return result_file_; }
       |                                                          ^~~~~~~~~~~~
../../../../src/Converter.h: In member function ‘const string& lyx::Converter::parselog() const’:
../../../../src/Converter.h:91:55: warning: returning reference to temporary [-Wreturn-local-addr]
    91 |         std::string const & parselog() const { return parselog_; }
       |                                                       ^~~~~~~~~
../../../../src/Converter.h: In member function ‘const string& lyx::Converter::hyperref_driver() const’:
../../../../src/Converter.h:93:62: warning: returning reference to temporary [-Wreturn-local-addr]
    93 |         std::string const & hyperref_driver() const { return href_driver_; }
       |                                                              ^~~~~~~~~~~~

-- 
Enrico


More information about the lyx-devel mailing list