[Bug c++/47396] New: Link error when declare a constant reference to a class or struct static const member!

2011-01-21 Thread aishen944 at 163 dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47396

   Summary: Link error when declare a constant reference to a
class or struct static const member!
   Product: gcc
   Version: 4.5.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: aishen...@163.com


if code like this:
struct test
{
 static const int uri = 10;
};

int main(void)
{
 const int &ref = test::uri;
}

errors:
[qiang@chenyq-fedora ~]$ g++ test.cc  
/tmp/ccwzRULi.o: In function `main':
test.cc:(.text+0x8): undefined reference to `test::uri'
collect2: ld returned 1 exit status


[Bug c++/47396] Link error when declare a constant reference to a class or struct static const member!

2011-01-21 Thread aishen944 at 163 dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47396

ChenYongqiang  changed:

   What|Removed |Added

 Status|RESOLVED|UNCONFIRMED
 Resolution|INVALID |

--- Comment #2 from ChenYongqiang  2011-01-21 
13:45:37 UTC ---
but like this:

struct test
{
static const int i = 0;
};

int main(void)
{
const unsigned int &m = test::i;
}


no link errors why???