From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25938 invoked by alias); 19 Mar 2005 14:34:23 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 25884 invoked by uid 48); 19 Mar 2005 14:34:18 -0000 Date: Sat, 19 Mar 2005 14:34:00 -0000 Message-ID: <20050319143418.25883.qmail@sourceware.org> From: "pinskia at gcc dot gnu dot org" To: gcc-bugs@gcc.gnu.org In-Reply-To: <20050319065920.20547.Hu.YuehWei@gmail.com> References: <20050319065920.20547.Hu.YuehWei@gmail.com> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug c++/20547] undefined reference to "static const" fields of classes X-Bugzilla-Reason: CC X-SW-Source: 2005-03/txt/msg02333.txt.bz2 List-Id: ------- Additional Comments From pinskia at gcc dot gnu dot org 2005-03-19 14:34 ------- (In reply to comment #5) > I understand what you mean. > But why the following codes works: > > #include > #include > > struct T > { > static char const a = 3; > }; > > std::vector ddd; > > int > main() > { > ddd.push_back(static_cast(T::a)); // <========= here > > std::cerr << ddd.front() << std::endl; > > return 0; > } > > and if I pass an constant to a function which takes its address, Because you changed an lvalue to a rvalue. > then why the folloing codes doesn't produce errors? Because constants are rvalues so there is going to be a temporary variable made for you. -- What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution| |INVALID http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20547