std::copy of volatile array triggers invalid conversion error

Bug #1644978 reported by poganoe
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
GNU Arm Embedded Toolchain
Confirmed
Undecided
Unassigned

Bug Description

I'm using arm-none-eabi-g++.exe (GNU Tools for ARM Embedded Processors) 5.4.1 20160919 (release) [ARM/embedded-5-branch revision 240496] for Windows. As far as I know it's the latest version of arm-none-eabi target.

I'm trying to compile this:

#include <algorithm>

volatile uint8_t buf[10];
volatile uint8_t dest[10];

int main(void)
{
    std::copy(buf, buf+5, dest);
    return 0;
}

And I get:

arm-none-eabi\include\c++\5.4.1\bits\stl_algobase.h:384:23: error: invalid conversion from 'volatile void*' to 'void*' [-fpermissive]
      __builtin_memmove(__result, __first, sizeof(_Tp) * _Num);
                       ^
<built-in>: note: initializing argument 1 of 'void* __builtin_memmove(void*, const void*, unsigned int)'
arm-none-eabi\include\c++\5.4.1\bits\stl_algobase.h:384:23: error: invalid conversion from 'const volatile void*' to 'const void*' [-fpermissive]
<built-in>: note: initializing argument 2 of 'void* __builtin_memmove(void*, const void*, unsigned int)'

I'm not sure if it's correct behaviour but it certainly doesn't seem like it. It should be possible to copy one array to the other array of the same type.

Revision history for this message
Thomas Preud'homme (thomas-preudhomme) wrote :

I can reproduce the issue but I cannot convince myself whether this is a bug or not. It seems indeed that this only gives an error because of the way std::copy is implemented: using __builtin_memmove which has non volatile parameters.

That said this is not ARM specific so I suggest you report the bug in GCC's bugzilla instead. This will reach C++ front end maintainers of GCC who will have a more definite opinion on the question.

Please post the bugzilla number here once you have done so.

Best regards.

Changed in gcc-arm-embedded:
status: New → Confirmed
Revision history for this message
poganoe (lamerishe) wrote :

I actually started with posting in GCC's bugzilla but than thought that it can be more specific. Here's the link https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78530

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.