[Bug c++/54483] undefined reference to static constexpr in .so

2024-01-17 Thread thiago at kde dot org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54483

--- Comment #13 from Thiago Macieira  ---
(In reply to Andrew Pinski from comment #11)
> You still need:
> constexpr float A::val;

In C++11 mode, yes.

C++17 made all static constexpr data members implicitly inline, which change
the situation. Inline variables ought to be emitted on use and merged at
runtime.

This explanation does not change the resolution of this bug report. But if you
can update your code to use -std=c++17, gnu++17 or later, then the problem goes
away.

[Bug c++/54483] undefined reference to static constexpr in .so

2024-01-17 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54483

Andrew Pinski  changed:

   What|Removed |Added

 CC||thiago at kde dot org

--- Comment #12 from Andrew Pinski  ---
*** Bug 113465 has been marked as a duplicate of this bug. ***

[Bug c++/54483] undefined reference to static constexpr in .so

2021-08-27 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54483

Andrew Pinski  changed:

   What|Removed |Added

 Status|REOPENED|RESOLVED
 Resolution|--- |INVALID

--- Comment #11 from Andrew Pinski  ---
(In reply to Mitsuru Kariya from comment #9)
> (In reply to Juisoo from comment #8)
> > However, if I add another data member which is initialized with val by
> > default, I still get the "undefined reference" error, see second attachment.
> 
> The second testcase is reduced like below.
> 
> == testcase ==
> struct A {
> static constexpr float val = 0.08;
> A(const float& = val) {}
> };
> 
> int main()
> {
> A{};
> }
> == testcase ==
> cf. http://melpon.org/wandbox/permlink/ZCbNwLlPQakWjluY

You still need:
constexpr float A::val;

[Bug c++/54483] undefined reference to static constexpr in .so

2016-02-10 Thread ddsherstennikov at ya dot ru
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54483

Denis Sherstennikov  changed:

   What|Removed |Added

 CC||ddsherstennikov at ya dot ru

--- Comment #10 from Denis Sherstennikov  ---
Still an issue at gcc 5.3.0.

[Bug c++/54483] undefined reference to static constexpr in .so

2015-03-25 Thread kariya_mitsuru at hotmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54483

Mitsuru Kariya kariya_mitsuru at hotmail dot com changed:

   What|Removed |Added

 CC||kariya_mitsuru at hotmail dot 
com

--- Comment #9 from Mitsuru Kariya kariya_mitsuru at hotmail dot com ---
(In reply to Juisoo from comment #8)
 However, if I add another data member which is initialized with val by
 default, I still get the undefined reference error, see second attachment.

The second testcase is reduced like below.

== testcase ==
struct A {
static constexpr float val = 0.08;
A(const float = val) {}
};

int main()
{
A{};
}
== testcase ==
cf. http://melpon.org/wandbox/permlink/ZCbNwLlPQakWjluY


I think that the testcase is ill-formed because the A::val is odr-used.

When A's ctor is called with no argument,
  1) The lvalue-to-rvalue conversion is not applied to A::val.
 (Since the ctor's parameter is a reference type.)
  2) A::val is not a discarded-value expression.


On the other hand, A::val is not odr-used in the first testcase.
(Since the builtin unary - operator requires that its operand is a prvalue.)


So, I think that this pr is fixed.
(But I don't know whether this pr can be closed since I cannot find a test.)


[Bug c++/54483] undefined reference to static constexpr in .so

2014-11-30 Thread usack at math dot fu-berlin.de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54483

Juisoo usack at math dot fu-berlin.de changed:

   What|Removed |Added

 CC||usack at math dot fu-berlin.de

--- Comment #6 from Juisoo usack at math dot fu-berlin.de ---
Created attachment 34147
  -- https://gcc.gnu.org/bugzilla/attachment.cgi?id=34147action=edit
Files for testcase of initial post


[Bug c++/54483] undefined reference to static constexpr in .so

2014-11-30 Thread usack at math dot fu-berlin.de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54483

--- Comment #7 from Juisoo usack at math dot fu-berlin.de ---
Created attachment 34148
  -- https://gcc.gnu.org/bugzilla/attachment.cgi?id=34148action=edit
second test case


[Bug c++/54483] undefined reference to static constexpr in .so

2014-11-30 Thread usack at math dot fu-berlin.de
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54483

--- Comment #8 from Juisoo usack at math dot fu-berlin.de ---
The described case seems to work in GCC 4.9.2  with the attached files and
g++ -c -fpic testicle.cc -std=c++11
g++ -shared -o libtesticle.so testicle.o 
g++ -L/home/usack/entwicklung/tetris -Wall -o testicles main.cc -ltesticle
-std=c++11

However, if I add another data member which is initialized with val by default,
I still get the undefined reference error, see second attachment.


[Bug c++/54483] undefined reference to static constexpr in .so

2012-09-07 Thread redi at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54483

--- Comment #5 from Jonathan Wakely redi at gcc dot gnu.org 2012-09-07 
08:30:36 UTC ---
(In reply to comment #3)
 (In reply to comment #1)
  This is invalid as per [class.static.data]/3 :
 
 On C++11 level it should be valid

http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#712 is post-C++11
but as a DR we should implement it for all values of -std


[Bug c++/54483] undefined reference to static constexpr in .so

2012-09-05 Thread jakub at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54483

Jakub Jelinek jakub at gcc dot gnu.org changed:

   What|Removed |Added

 CC||jakub at gcc dot gnu.org

--- Comment #1 from Jakub Jelinek jakub at gcc dot gnu.org 2012-09-05 
07:49:57 UTC ---
This is invalid as per [class.static.data]/3 :
A static data member of literal type can be declared in the class definition
with the constexpr specifier; if so, its declaration shall specify a
brace-or-equal-initializer in which every initializer-clause that is an
assignment-expression is a constant expression. [ Note: In both these cases,
the member may appear in constant expressions. — end note ] The member shall
still be defined in a namespace scope if it is odr-used (3.2) in the program
and the namespace scope definition shall not contain an initializer.


[Bug c++/54483] undefined reference to static constexpr in .so

2012-09-05 Thread rguenth at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54483

Richard Guenther rguenth at gcc dot gnu.org changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution||INVALID

--- Comment #2 from Richard Guenther rguenth at gcc dot gnu.org 2012-09-05 
09:21:42 UTC ---
.


[Bug c++/54483] undefined reference to static constexpr in .so

2012-09-05 Thread daniel.kruegler at googlemail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54483

--- Comment #3 from Daniel Krügler daniel.kruegler at googlemail dot com 
2012-09-05 11:12:13 UTC ---
(In reply to comment #1)
 This is invalid as per [class.static.data]/3 :

On C++11 level it should be valid, because odr-usage does not happen here
according to [basic.def.odr] p3:

A variable x whose name appears as a potentially-evaluated expression ex is
odr-used unless x is an object that satisfies the requirements for appearing in
a constant expression (5.19) and ex is an element of the set of potential
results of an expression e, where either the lvalue-to-rvalue conversion (4.1)
is applied
to e, or e is a discarded-value expression (Clause 5).


[Bug c++/54483] undefined reference to static constexpr in .so

2012-09-05 Thread paolo.carlini at oracle dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54483

Paolo Carlini paolo.carlini at oracle dot com changed:

   What|Removed |Added

 Status|RESOLVED|REOPENED
   Last reconfirmed||2012-09-05
 Resolution|INVALID |
 Ever Confirmed|0   |1

--- Comment #4 from Paolo Carlini paolo.carlini at oracle dot com 2012-09-05 
11:21:06 UTC ---
Let's reopen this, then.