public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/42101]  New: Linking failure with static constants and ternary inline function
@ 2009-11-19  1:42 dvander at alliedmods dot net
  2009-11-19  1:44 ` [Bug c++/42101] " dvander at alliedmods dot net
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: dvander at alliedmods dot net @ 2009-11-19  1:42 UTC (permalink / raw)
  To: gcc-bugs

When using private, static constants in a class declaration, and using these
constants in an inline function that returns a ternary expression , gcc
produces linker errors.

This seems to be a problem going back to at least 4.0, and I can reproduce it
against 4.4.1. I have not tried anything earlier than 4.0 or later than 4.4.1.


-- 
           Summary: Linking failure with static constants and ternary inline
                    function
           Product: gcc
           Version: 4.4.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dvander at alliedmods dot net
  GCC host triplet: x86_64-linux-gnu
GCC target triplet: x86_64-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42101


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug c++/42101] Linking failure with static constants and ternary inline function
  2009-11-19  1:42 [Bug c++/42101] New: Linking failure with static constants and ternary inline function dvander at alliedmods dot net
@ 2009-11-19  1:44 ` dvander at alliedmods dot net
  2009-11-19  1:47 ` pinskia at gcc dot gnu dot org
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: dvander at alliedmods dot net @ 2009-11-19  1:44 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 738 bytes --]



------- Comment #1 from dvander at alliedmods dot net  2009-11-19 01:44 -------
Created an attachment (id=19039)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=19039&action=view)
reduced test case

This program doesn't link, though it should.

keima:src dvander$ g++ test.cpp -o test
test.cpp: In function ‘int main()’:
test.cpp:28: warning: format ‘%d’ expects type ‘int’, but argument 2 has type
‘size_t’
Undefined symbols:
  "X::LENGTH_MASK", referenced from:
      X::dependentLength() const in ccdhJ0JB.o
  "X::DEPENDENT_LENGTH_MASK", referenced from:
      X::dependentLength() const in ccdhJ0JB.o
ld: symbol(s) not found
collect2: ld returned 1 exit status


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42101


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug c++/42101] Linking failure with static constants and ternary inline function
  2009-11-19  1:42 [Bug c++/42101] New: Linking failure with static constants and ternary inline function dvander at alliedmods dot net
  2009-11-19  1:44 ` [Bug c++/42101] " dvander at alliedmods dot net
@ 2009-11-19  1:47 ` pinskia at gcc dot gnu dot org
  2009-11-19  1:52 ` andhow at gmail dot com
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-11-19  1:47 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from pinskia at gcc dot gnu dot org  2009-11-19 01:46 -------
You don't have a definition of the static const variable which you need for
this to be valid C++.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42101


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug c++/42101] Linking failure with static constants and ternary inline function
  2009-11-19  1:42 [Bug c++/42101] New: Linking failure with static constants and ternary inline function dvander at alliedmods dot net
  2009-11-19  1:44 ` [Bug c++/42101] " dvander at alliedmods dot net
  2009-11-19  1:47 ` pinskia at gcc dot gnu dot org
@ 2009-11-19  1:52 ` andhow at gmail dot com
  2009-11-19  1:53 ` andhow at gmail dot com
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: andhow at gmail dot com @ 2009-11-19  1:52 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from andhow at gmail dot com  2009-11-19 01:52 -------
(In reply to comment #2)
> You don't have a definition of the static const variable which you need for
> this to be valid C++.


-- 

andhow at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andhow at gmail dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42101


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug c++/42101] Linking failure with static constants and ternary inline function
  2009-11-19  1:42 [Bug c++/42101] New: Linking failure with static constants and ternary inline function dvander at alliedmods dot net
                   ` (2 preceding siblings ...)
  2009-11-19  1:52 ` andhow at gmail dot com
@ 2009-11-19  1:53 ` andhow at gmail dot com
  2009-11-19  1:59 ` dvander at alliedmods dot net
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: andhow at gmail dot com @ 2009-11-19  1:53 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from andhow at gmail dot com  2009-11-19 01:53 -------
(In reply to comment #3)
> (In reply to comment #2)
> > You don't have a definition of the static const variable which you need for
> > this to be valid C++.

Heh, oops, hit 'Commit' accidentally.

This example does have a definition for the static member variable.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42101


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug c++/42101] Linking failure with static constants and ternary inline function
  2009-11-19  1:42 [Bug c++/42101] New: Linking failure with static constants and ternary inline function dvander at alliedmods dot net
                   ` (3 preceding siblings ...)
  2009-11-19  1:53 ` andhow at gmail dot com
@ 2009-11-19  1:59 ` dvander at alliedmods dot net
  2009-11-19  2:16 ` paolo dot carlini at oracle dot com
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: dvander at alliedmods dot net @ 2009-11-19  1:59 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from dvander at alliedmods dot net  2009-11-19 01:58 -------
I'll also note that the compiler seems to accept it, as I get a .o file. The
linking step botches.


-- 

dvander at alliedmods dot net changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|INVALID                     |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42101


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug c++/42101] Linking failure with static constants and ternary inline function
  2009-11-19  1:42 [Bug c++/42101] New: Linking failure with static constants and ternary inline function dvander at alliedmods dot net
                   ` (4 preceding siblings ...)
  2009-11-19  1:59 ` dvander at alliedmods dot net
@ 2009-11-19  2:16 ` paolo dot carlini at oracle dot com
  2009-11-19  2:41 ` andhow at gmail dot com
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: paolo dot carlini at oracle dot com @ 2009-11-19  2:16 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from paolo dot carlini at oracle dot com  2009-11-19 02:16 -------
It doesn't have any definition, it does have a *declaration*. This is pretty
basic C++, by the way. Just add out of class:

  const size_t X::DEPENDENT_LENGTH_MASK;
  ...
  ...

and everything will be fine. The compiler doesn't diagnose that, right, because
the actual diagnosis, as for any undefined entity, eg, functions, happens only
at link time, the linker tells you: as happens for functions, you could well
have the definitions in another file.


-- 

paolo dot carlini at oracle dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42101


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug c++/42101] Linking failure with static constants and ternary inline function
  2009-11-19  1:42 [Bug c++/42101] New: Linking failure with static constants and ternary inline function dvander at alliedmods dot net
                   ` (5 preceding siblings ...)
  2009-11-19  2:16 ` paolo dot carlini at oracle dot com
@ 2009-11-19  2:41 ` andhow at gmail dot com
  2009-11-19  9:38 ` paolo dot carlini at oracle dot com
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: andhow at gmail dot com @ 2009-11-19  2:41 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from andhow at gmail dot com  2009-11-19 02:41 -------
(In reply to comment #6)

> This is pretty basic C++, by the way.

Mmm hmm. SO basic that it warranted special clarification in 9.4.2-4:

"The member shall still be defined in a namespace scope if it is used in the
program and the namespace scope definition shall not contain an initializer."


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42101


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug c++/42101] Linking failure with static constants and ternary inline function
  2009-11-19  1:42 [Bug c++/42101] New: Linking failure with static constants and ternary inline function dvander at alliedmods dot net
                   ` (6 preceding siblings ...)
  2009-11-19  2:41 ` andhow at gmail dot com
@ 2009-11-19  9:38 ` paolo dot carlini at oracle dot com
  2009-12-01 17:07 ` pinskia at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: paolo dot carlini at oracle dot com @ 2009-11-19  9:38 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from paolo dot carlini at oracle dot com  2009-11-19 09:38 -------
It is basic, yes, a point worth making with people insisting that we do have a
serious bug, thus reopening the PR at will, without trusting the competence of
the maintainers and wasting some of our time.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42101


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug c++/42101] Linking failure with static constants and ternary inline function
  2009-11-19  1:42 [Bug c++/42101] New: Linking failure with static constants and ternary inline function dvander at alliedmods dot net
                   ` (7 preceding siblings ...)
  2009-11-19  9:38 ` paolo dot carlini at oracle dot com
@ 2009-12-01 17:07 ` pinskia at gcc dot gnu dot org
  2009-12-08  9:18 ` paolo dot carlini at oracle dot com
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-12-01 17:07 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from pinskia at gcc dot gnu dot org  2009-12-01 17:07 -------
*** Bug 42241 has been marked as a duplicate of this bug. ***


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |halterman at southern dot
                   |                            |edu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42101


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug c++/42101] Linking failure with static constants and ternary inline function
  2009-11-19  1:42 [Bug c++/42101] New: Linking failure with static constants and ternary inline function dvander at alliedmods dot net
                   ` (8 preceding siblings ...)
  2009-12-01 17:07 ` pinskia at gcc dot gnu dot org
@ 2009-12-08  9:18 ` paolo dot carlini at oracle dot com
  2009-12-08  9:49 ` redi at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: paolo dot carlini at oracle dot com @ 2009-12-08  9:18 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from paolo dot carlini at oracle dot com  2009-12-08 09:18 -------
*** Bug 42330 has been marked as a duplicate of this bug. ***


-- 

paolo dot carlini at oracle dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |aijunbai at gmail dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42101


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug c++/42101] Linking failure with static constants and ternary inline function
  2009-11-19  1:42 [Bug c++/42101] New: Linking failure with static constants and ternary inline function dvander at alliedmods dot net
                   ` (9 preceding siblings ...)
  2009-12-08  9:18 ` paolo dot carlini at oracle dot com
@ 2009-12-08  9:49 ` redi at gcc dot gnu dot org
  2010-03-31  0:14 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: redi at gcc dot gnu dot org @ 2009-12-08  9:49 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #11 from redi at gcc dot gnu dot org  2009-12-08 09:48 -------
*** Bug 42330 has been marked as a duplicate of this bug. ***


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42101


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug c++/42101] Linking failure with static constants and ternary inline function
  2009-11-19  1:42 [Bug c++/42101] New: Linking failure with static constants and ternary inline function dvander at alliedmods dot net
                   ` (10 preceding siblings ...)
  2009-12-08  9:49 ` redi at gcc dot gnu dot org
@ 2010-03-31  0:14 ` pinskia at gcc dot gnu dot org
  2010-05-20 17:54 ` pinskia at gcc dot gnu dot org
  2010-06-13 17:53 ` paolo dot carlini at oracle dot com
  13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2010-03-31  0:14 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #12 from pinskia at gcc dot gnu dot org  2010-03-31 00:14 -------
*** Bug 43594 has been marked as a duplicate of this bug. ***


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rwgk at yahoo dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42101


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug c++/42101] Linking failure with static constants and ternary inline function
  2009-11-19  1:42 [Bug c++/42101] New: Linking failure with static constants and ternary inline function dvander at alliedmods dot net
                   ` (11 preceding siblings ...)
  2010-03-31  0:14 ` pinskia at gcc dot gnu dot org
@ 2010-05-20 17:54 ` pinskia at gcc dot gnu dot org
  2010-06-13 17:53 ` paolo dot carlini at oracle dot com
  13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2010-05-20 17:54 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #13 from pinskia at gcc dot gnu dot org  2010-05-20 17:53 -------
*** Bug 44215 has been marked as a duplicate of this bug. ***


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |doreille at smr dot ch


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42101


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [Bug c++/42101] Linking failure with static constants and ternary inline function
  2009-11-19  1:42 [Bug c++/42101] New: Linking failure with static constants and ternary inline function dvander at alliedmods dot net
                   ` (12 preceding siblings ...)
  2010-05-20 17:54 ` pinskia at gcc dot gnu dot org
@ 2010-06-13 17:53 ` paolo dot carlini at oracle dot com
  13 siblings, 0 replies; 15+ messages in thread
From: paolo dot carlini at oracle dot com @ 2010-06-13 17:53 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #14 from paolo dot carlini at oracle dot com  2010-06-13 17:53 -------
*** Bug 44528 has been marked as a duplicate of this bug. ***


-- 

paolo dot carlini at oracle dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |gcc at razorcam dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42101


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2010-06-13 17:53 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-19  1:42 [Bug c++/42101] New: Linking failure with static constants and ternary inline function dvander at alliedmods dot net
2009-11-19  1:44 ` [Bug c++/42101] " dvander at alliedmods dot net
2009-11-19  1:47 ` pinskia at gcc dot gnu dot org
2009-11-19  1:52 ` andhow at gmail dot com
2009-11-19  1:53 ` andhow at gmail dot com
2009-11-19  1:59 ` dvander at alliedmods dot net
2009-11-19  2:16 ` paolo dot carlini at oracle dot com
2009-11-19  2:41 ` andhow at gmail dot com
2009-11-19  9:38 ` paolo dot carlini at oracle dot com
2009-12-01 17:07 ` pinskia at gcc dot gnu dot org
2009-12-08  9:18 ` paolo dot carlini at oracle dot com
2009-12-08  9:49 ` redi at gcc dot gnu dot org
2010-03-31  0:14 ` pinskia at gcc dot gnu dot org
2010-05-20 17:54 ` pinskia at gcc dot gnu dot org
2010-06-13 17:53 ` paolo dot carlini at oracle dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).