https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69302
Bug ID: 69302
Summary: Using bswap in template function with
-ftrack-macro-expansion=0 results in a false compiler
error
Product: gcc
Version: 5.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: kholdstare0.0 at gmail dot com
Target Milestone: ---
Here is the a minimal test.cpp:
#include <byteswap.h>
template <typename BLAH>
unsigned int foo()
{
return bswap_32(0x00000FFF);
}
unsigned int bar()
{
return foo<int>();
}
If the template is removed, everything compiles fine. The compilation command:
g++ -std=c++1y -c -ftrack-macro-expansion=0 -Werror -Wall -Wextra
test.cpp -o test.o
If -ftrack-macro-expansion=0 is removed, everything compiles fine. The error
that results:
main.cpp: In instantiation of 'unsigned int foo() [with BLAH = int]':
main.cpp:11:18: required from here
main.cpp:6:9: error: address requested for '__x', which is declared
'register' [-Werror=extra]
return bswap_32(0x00000FFF);
^
cc1plus: all warnings being treated as errors
This is eerily reminiscent of these bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57573
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60955