public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/43368]  New: different access to templated structure static field give different results
@ 2010-03-14 20:25 pogonyshev at gmx dot net
  2010-03-14 23:27 ` [Bug c++/43368] [4.3/4.4/4.5 Regression] " hjl dot tools at gmail dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: pogonyshev at gmx dot net @ 2010-03-14 20:25 UTC (permalink / raw)
  To: gcc-bugs

Tested with Debian testing 4.4.3-3 and 4.3.4-8.

Compiling this code snippet:

template <int& field>
struct Foo
{
  static  int
  bar ()
  {  return field;  }
};

template <bool>
struct X
{
  static  int  x;
  typedef  Foo <x>  foo;
};

// This makes first statement in main() compile, but not the second...
template <>
int  X <false>::x = 0;

int
main ()
{
  X <false>::x;
  X <false>::foo::bar ();
}

with 'g++ test.cpp -o test' gives the following error on linking stage:

/tmp/ccuo8N2e.o: In function `_ZN3FooILZN1XIXT_EE1xEEE3barEv':
test.cpp:(.text._ZN3FooILZN1XIXT_EE1xEEE3barEv[_ZN3FooILZN1XIXT_EE1xEEE3barEv]+0x4):
undefined reference to `_ZN1XIXT_EE1xE'

This is a regression: it works with 4.1, but doesn't with 4.3 or 4.4.  Didn't
test 4.2.


-- 
           Summary: different access to templated structure static field
                    give different results
           Product: gcc
           Version: 4.4.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: pogonyshev at gmx dot net
 GCC build triplet: i486-pc-linux-gnu
  GCC host triplet: i486-pc-linux-gnu
GCC target triplet: i486-pc-linux-gnu


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


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

* [Bug c++/43368] [4.3/4.4/4.5 Regression] different access to templated structure static field give different results
  2010-03-14 20:25 [Bug c++/43368] New: different access to templated structure static field give different results pogonyshev at gmx dot net
@ 2010-03-14 23:27 ` hjl dot tools at gmail dot com
  2010-03-15 10:32 ` redi at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: hjl dot tools at gmail dot com @ 2010-03-14 23:27 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from hjl dot tools at gmail dot com  2010-03-14 23:27 -------
It is caused by revision 131044:

http://gcc.gnu.org/ml/gcc-cvs/2007-12/msg00495.html


-- 

hjl dot tools at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at redhat dot com
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2010-03-14 23:27:09
               date|                            |


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


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

* [Bug c++/43368] [4.3/4.4/4.5 Regression] different access to templated structure static field give different results
  2010-03-14 20:25 [Bug c++/43368] New: different access to templated structure static field give different results pogonyshev at gmx dot net
  2010-03-14 23:27 ` [Bug c++/43368] [4.3/4.4/4.5 Regression] " hjl dot tools at gmail dot com
@ 2010-03-15 10:32 ` redi at gcc dot gnu dot org
  2010-03-15 11:20 ` rguenth at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu dot org @ 2010-03-15 10:32 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from redi at gcc dot gnu dot org  2010-03-15 10:32 -------
Is this valid?
The 'foo' typedef needs the address of X::x but occurs before it has been
defined.

Comeau gives
line 18: error: explicit specialization of member
          "X<<unnamed>>::x [with <unnamed>=false]" must precede its first use (
          at line 13)


-- 


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


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

* [Bug c++/43368] [4.3/4.4/4.5 Regression] different access to templated structure static field give different results
  2010-03-14 20:25 [Bug c++/43368] New: different access to templated structure static field give different results pogonyshev at gmx dot net
  2010-03-14 23:27 ` [Bug c++/43368] [4.3/4.4/4.5 Regression] " hjl dot tools at gmail dot com
  2010-03-15 10:32 ` redi at gcc dot gnu dot org
@ 2010-03-15 11:20 ` rguenth at gcc dot gnu dot org
  2010-03-15 12:22 ` redi at gcc dot gnu dot org
  2010-03-15 13:20 ` [Bug c++/43368] " rguenth at gcc dot gnu dot org
  4 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-03-15 11:20 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from rguenth at gcc dot gnu dot org  2010-03-15 11:20 -------
EDG agrees.  But accepts the code without the explicit specialization.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.3.5


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


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

* [Bug c++/43368] [4.3/4.4/4.5 Regression] different access to templated structure static field give different results
  2010-03-14 20:25 [Bug c++/43368] New: different access to templated structure static field give different results pogonyshev at gmx dot net
                   ` (2 preceding siblings ...)
  2010-03-15 11:20 ` rguenth at gcc dot gnu dot org
@ 2010-03-15 12:22 ` redi at gcc dot gnu dot org
  2010-03-15 13:20 ` [Bug c++/43368] " rguenth at gcc dot gnu dot org
  4 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu dot org @ 2010-03-15 12:22 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from redi at gcc dot gnu dot org  2010-03-15 12:22 -------
14.7.3 [temp.expl.spec] p6 says:

If a template, a member template or the member of a class template is
explicitly specialized then that specialization
shall be declared before the first use of that specialization that would cause
an implicit instantiation
to take place, in every translation unit in which such a use occurs; no
diagnostic is required.


-- 


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


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

* [Bug c++/43368] different access to templated structure static field give different results
  2010-03-14 20:25 [Bug c++/43368] New: different access to templated structure static field give different results pogonyshev at gmx dot net
                   ` (3 preceding siblings ...)
  2010-03-15 12:22 ` redi at gcc dot gnu dot org
@ 2010-03-15 13:20 ` rguenth at gcc dot gnu dot org
  4 siblings, 0 replies; 7+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-03-15 13:20 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from rguenth at gcc dot gnu dot org  2010-03-15 13:20 -------
Not a regression.  Diagnostic enhancement possible.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement
           Keywords|                            |accepts-invalid, diagnostic
            Summary|[4.3/4.4/4.5 Regression]    |different access to
                   |different access to         |templated structure static
                   |templated structure static  |field give different results
                   |field give different results|
   Target Milestone|4.3.5                       |---


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


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

* [Bug c++/43368] different access to templated structure static field give different results
       [not found] <bug-43368-4@http.gcc.gnu.org/bugzilla/>
@ 2021-07-24  0:33 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-07-24  0:33 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43368

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
      Known to fail|                            |
         Resolution|---                         |DUPLICATE

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This is a dup of bug 22354.

*** This bug has been marked as a duplicate of bug 22354 ***

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

end of thread, other threads:[~2021-07-24  0:33 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-14 20:25 [Bug c++/43368] New: different access to templated structure static field give different results pogonyshev at gmx dot net
2010-03-14 23:27 ` [Bug c++/43368] [4.3/4.4/4.5 Regression] " hjl dot tools at gmail dot com
2010-03-15 10:32 ` redi at gcc dot gnu dot org
2010-03-15 11:20 ` rguenth at gcc dot gnu dot org
2010-03-15 12:22 ` redi at gcc dot gnu dot org
2010-03-15 13:20 ` [Bug c++/43368] " rguenth at gcc dot gnu dot org
     [not found] <bug-43368-4@http.gcc.gnu.org/bugzilla/>
2021-07-24  0:33 ` pinskia at gcc dot gnu.org

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).