Skip to content

CLANG 18 - base64.cpp: error: ISO C++17 does not allow 'register' storage class specifier [-Wregister] #36

Description

@micfogas

Compiling lsmcd on AlmaLinux 9. I received an error on base64.cpp during compile as follows, though the error also occurs in several other files, depending how many parallel processes are used:
base64.cpp:36:5: error: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
36 | register const char *pEncoded = encoded;
| ^~~~~~~~
base64.cpp:37:5: error: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
37 | register unsigned char e1, prev_e = 0;
| ^~~~~~~~
base64.cpp:37:5: error: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
37 | register unsigned char e1, prev_e = 0;
| ^~~~~~~~
base64.cpp:38:5: error: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
38 | register char phase = 0;
| ^~~~~~~~
base64.cpp:39:5: error: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
39 | register unsigned char *pDecoded = (unsigned char *)decoded;
| ^~~~~~~~
base64.cpp:40:5: error: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
40 | register const char *pEnd = encoded + size ;
| ^~~~~~~~
base64.cpp:44:9: error: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
44 | register int ch = *pEncoded++;
| ^~~~~~~~
base64.cpp:75:5: error: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
75 | register const unsigned char *pDecoded = (const unsigned char *)decoded;
| ^~~~~~~~
base64.cpp:76:5: error: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
76 | register constmv -f .deps/autobuf.Tpo .deps/autobuf.Po unsigned char *pEnd = (const unsigned char *)decoded + size
| ^~~~~~~~
base64.cpp:78:5: error: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
clang -DHAVE_CONFIG_H -I. -I../../src -I../../include -I../../src -I/usr/include -g -O2 -fstack-protector -MT blockbuf.o -MD -MP -MF .deps/blockbuf.Tpo -c -o blockbuf.o blockbuf.cpp
78 | register char *pEncoded = encoded;
| ^~~~~~~~
base64.cpp:79:5: error: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
79 | register unsigned char ch;
| ^~~~~~~~
11 errors generated.
make[4]: *** [Makefile:600: base64.o] Error 1

My configure command is:
CC="clang" CXX="clang" "LDFLAGS=" -fuse-ld=lld" CFLAGS=" -O2" ./configure --prefix=/usr/local/lsmcd

EL9 comes pre-installed with gcc 11:
gcc (GCC) 11.5.0 20240719 (Red Hat 11.5.0-2)

The packaged clang on EL9 is clang 18:
clang version 18.1.8 (AlmaLinux OS Foundation 18.1.8-3.el9)

I have attached my config.log file.
config.log


register pointers are only warnings in gcc, but fatal errors in clang.

Adding CXXFLAGS="-Wno-register" on the configure command line will allow clang to complete the compile without the errors, and will skip the warnings in gcc.

However, the solution for ISO C++ 17 should be to rename register to REGISTER, or avoid the register keyword all together.

gcc has used ISO C++ 17 since gcc 8. These warnings are being thrown for any modern compilers. Hopefully an update will rename register if ISO C++ 17 is detected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions