• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: GCC issue: No error on in-class initialization of non-integral static const variables
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GCC issue: No error on in-class initialization of non-integral static const variables


  • Subject: Re: GCC issue: No error on in-class initialization of non-integral static const variables
  • From: "Justin C. Walker" <email@hidden>
  • Date: Sun, 10 Jul 2005 22:46:11 -0700


On Jul 10, 2005, at 22:35 , Zachary Pincus wrote:

According to the C++ standard (I think! Correct if wrong.), in- class initialization of static const integral types is permitted.

That is:
struct Foo {
  static const int bar = 10;
};

is ok, whereas if 'bar' were not an integral type (enum, int, etc.) but a float or pointer or so forth, it would not be permitted.

Now, previous versions of GCC didn't mind when 'bar' was a float, etc. But with GCC's push to better standards compliance, this is no longer allowed.

The only problem is that GCC doesn't produce an error about this. It's only at link-time (or worse, run-time, if '-undefined dynamic_lookup' is used) that this causes an 'undefined symbol' error.

If you use "-pedantic", it will tell you what you want to know :-}

$ c++ -pedantic bif.cc
bif.cc:2: error: ISO C++ forbids initialization of member constant 'bar' of non-integral type 'const float'


Regards,

Justin

--
Justin C. Walker, Curmudgeon-at-Large
/~\ The ASCII
\ / Ribbon Campaign
 X  Help Cure HTML Email
/ \


_______________________________________________ Do not post admin requests to the list. They will be ignored. Xcode-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: GCC issue: No error on in-class initialization of non-integral static const variables
      • From: Zachary Pincus <email@hidden>
References: 
 >GCC issue: No error on in-class initialization of non-integral static const variables (From: Zachary Pincus <email@hidden>)

  • Prev by Date: GCC issue: No error on in-class initialization of non-integral static const variables
  • Next by Date: Re: GCC issue: No error on in-class initialization of non-integral static const variables
  • Previous by thread: GCC issue: No error on in-class initialization of non-integral static const variables
  • Next by thread: Re: GCC issue: No error on in-class initialization of non-integral static const variables
  • Index(es):
    • Date
    • Thread