[Bug c++/97580] New: reinterpret_cast<> and constant expression
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97580 Bug ID: 97580 Summary: reinterpret_cast<> and constant expression Product: gcc Version: 7.5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: wolfgang.roe...@gi-de.com Target Milestone: --- Hi, I would like to post a bug report for the GNU C/C++ compiler 7.5.0. We use the compiler to generate code for a PowerPC processor. Invokation line for the GNU C++ compiler: ccppc -c -x c++ --std=gnu++17 -Wall -Werror -g -mcpu=e6500 -m32 -maltivec -mvrsave -ftls-model=local-exec -msdata=sysv -fno-common -fno-openmp -mbig -mmultiple -mno-string -misel -mstrict-align -fverbose-asm -G 8 -O3 -I -D X.CPP -oX.O // file X.CPP using T_PTR_FUNC = void (*)(int*); void func1 (int*); void func2 (float*); constexpr T_PTR_FUNC arrFuncs[] = { func1, reinterpret_cast(func2) }; The compiler accepts this code even though a reinterpret_cast<> fails to be a constant expression (cf. C++17 standard, 8.20/2). With kind regards W. Roehrl
[Bug c++/99001] New: indirect modification of function parameters
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99001 Bug ID: 99001 Summary: indirect modification of function parameters Product: gcc Version: 7.5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: wolfgang.roe...@gi-de.com Target Milestone: --- Hi, I would like to post a bug report for the GNU C/C++ compiler 7.5.0. We use the compiler to generate code for a PowerPC processor. Invokation line for the GNU C++ compiler: ccppc -c -x c++ --std=gnu++17 -Wall -Werror -g -mcpu=e6500 -m32 -maltivec -mvrsave -ftls-model=local-exec -msdata=sysv -fno-common -fno-openmp -mbig -mmultiple -mno-string -misel -mstrict-align -fverbose-asm -G 8 -O3 -I -D X.CPP -oX.O // file X.CPP struct X { X (int& r) : rr(r) {} ~X () { rr = 0; } int& rr; }; int f1 (int i) { { X x(i); } return i; } int f2 (int i) { X x(i); return i; } Wenn we compile this program the functions do the following: - function f1() returns 0 - independently of the value of parameter i; - function f2() returns the unmodified value of parameter i. I think that the behaviour of f2() is wrong and f2() should behave as function f1() does. With kind regards W. Roehrl
[Bug c++/100498] New: SFINAE and static inline function
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100498 Bug ID: 100498 Summary: SFINAE and static inline function Product: gcc Version: 7.5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: wolfgang.roe...@gi-de.com Target Milestone: --- Hi, I would like to post a bug report for the GNU C/C++ compiler 7.5.0. We use the compiler to generate code for a PowerPC processor. Invokation line for the GNU C++ compiler: ccppc -c -x c++ --std=gnu++17 -Wall -Werror -g -mcpu=e6500 -m32 -maltivec -mvrsave -ftls-model=local-exec -msdata=sysv -fno-common -fno-openmp -mbig -mmultiple -mno-string -misel -mstrict-align -fverbose-asm -G 8 -O3 -I -D X.CPP -oX.O // file X.CPP void f1 (int) {} inline void f1 (float) {} struct X { friend void f1 (int*) {} }; void f1 (int*); template struct SFINAE { static constexpr F_* ptr = nullptr; }; template struct SFINAE< F_, decltype((void)static_cast(f1), void()) > { static constexpr F_* ptr = f1; }; void func () { using F1 = void(int); constexpr F1* ptr1{ SFINAE::ptr }; static_assert (ptr1 != nullptr); using F2 = void(float); constexpr F2* ptr2{ SFINAE::ptr }; static_assert (ptr2 != nullptr); using F3 = void(int*); constexpr F3* ptr3{ SFINAE::ptr }; static_assert (ptr3 != nullptr); } Wenn we compile this program we get the following error messages: x.CPP: In function 'void func()': x.CPP:29:5: error: non-constant condition for static assertion static_assert (ptr2 != nullptr); ^ x.CPP:29:25: error: '(f1 != 0)' is not a constant expression static_assert (ptr2 != nullptr); ~^~ x.CPP:33:5: error: non-constant condition for static assertion static_assert (ptr3 != nullptr); ^ x.CPP:33:25: error: '(f1 != 0)' is not a constant expression static_assert (ptr3 != nullptr); ~^~ The reason for the first error messages is the inline attribute of function "void f1 (float)"; the error messages disappear if "inline" is removed. I I think this is not standard compliant. A similar problem seems to arise with function "void f1 (int*)". With kind regards W. Roehrl
[Bug c++/100498] SFINAE and static inline function
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100498 --- Comment #2 from Wolfgang Roehrl --- @Jonathan Wakely: Thank you very much for the detailled answer. Using this info it was possible for us to patch our 7.5 compiler version. At the moment we are constrained to use a 7.x compiler because we need support for the PowerPC e500 core. (To our knowledge this support has been phased out with the 8.x versions.)