← Back to team overview

kicad-developers team mailing list archive

Re: compile warnings about copying loop variable

 

Got it. I'll just leave it as it is then and try to remember to set
-Wno-range-loop-analysis the next time I build.

On Wed, Mar 10, 2021 at 3:20 PM Seth Hillbrand <seth@xxxxxxxxxxxxx> wrote:

> Almost certainly not.  These warnings are that the string is going to be
> copied one way or another, so we shouldn't be marking them for reference
> because it is misleading.  There may be a way for us to improve the code in
> places, knowing that the values cannot be referenced but just removing the
> references will make the code do the same thing, just without the warning.
>
> -Seth
>
> On Wed, Mar 10, 2021 at 6:13 AM Jonatan Liljedahl <lijon@xxxxxxxxxxxx>
> wrote:
>
>> Would it make any noticeable performance improvements, avoiding all those
>> string copying?
>>
>> On Wed, Mar 10, 2021 at 2:58 PM Seth Hillbrand <seth@xxxxxxxxxxxxx>
>> wrote:
>>
>>> That's fun!  New warning flags.  Those are from -Wrange-loop-analysis
>>> that is specific to clang.  Those of us using gcc won't see them.
>>>
>>> They are suggesting minor improvements.  You should feel free to submit
>>> a MR to correct these cases or you can set your flags to
>>> -Wno-range-loop-analysis to disable them.
>>>
>>> Best-
>>> Seth
>>>
>>> On Wed, Mar 10, 2021 at 5:26 AM Jonatan Liljedahl <lijon@xxxxxxxxxxxx>
>>> wrote:
>>>
>>>> I get a lot of compile warnings like this:
>>>>
>>>> In file included from
>>>> /Users/lijon/Coding/kicad/include/dialog_shim.h:29:
>>>> /Users/lijon/Coding/kicad/include/hashtables.h:87:26: warning: loop
>>>> variable 'c' is always a copy because the range of type 'const
>>>> wxString' does not return a reference
>>>>       [-Wrange-loop-analysis]
>>>>         for( const auto& c : aString )
>>>>                          ^
>>>> /Users/lijon/Coding/kicad/include/hashtables.h:87:14: note: use
>>>> non-reference type 'wxUniChar'
>>>>         for( const auto& c : aString )
>>>>              ^~~~~~~~~~~~~~~
>>>>
>>>>
>>>> --
>>>> /Jonatan
>>>> http://kymatica.com
>>>>
>>>> _______________________________________________
>>>> Mailing list: https://launchpad.net/~kicad-developers
>>>> Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
>>>> Unsubscribe : https://launchpad.net/~kicad-developers
>>>> More help   : https://help.launchpad.net/ListHelp
>>>>
>>>
>>>
>>> --
>>> [image: KiCad Services Corporation Logo]
>>> Seth Hillbrand
>>> *Lead Developer*
>>> +1-530-302-5483‬
>>> Long Beach, CA
>>> www.kipro-pcb.com    info@xxxxxxxxxxxxx
>>>
>>
>>
>> --
>> /Jonatan
>> http://kymatica.com
>>
>
>
> --
> [image: KiCad Services Corporation Logo]
> Seth Hillbrand
> *Lead Developer*
> +1-530-302-5483‬
> Long Beach, CA
> www.kipro-pcb.com    info@xxxxxxxxxxxxx
>


-- 
/Jonatan
http://kymatica.com

References