Closed Bug 681036 Opened 13 years ago Closed 13 years ago

Fix c++0x initializer list error found by clang

Categories

(Core Graveyard :: Plug-ins, defect)

x86_64
Linux
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
mozilla9

People

(Reporter: espindola, Assigned: espindola)

Details

Attachments

(1 file)

      No description provided.
in c++ one cannot use an unsigned int in an initalizer list position that wants an int. Unfortunately we cannot change the type of the variables because XGetGeometry expects unsigned pointers.
Is this new to c++0x?
Are you able to quote the relevant sentences in the spec, please?
Surely we can do

unsigned int a = 1;
signed int b = a;

In WG21/N1043,

"initializer:
= initializer-clause
( expression-list )

initializer-clause:
assignment-expression
{ initializer-list ,opt }
{ }

initializer-list:
initializer-clause
initializer-list , initializer-clause"

so initializer-lists are just a series of initializer-clauses.

and

"All implicit type conversions (4) are considered when initializing the aggregate member with an initializer
from an initializer-list."

Is there a backward-incompatible change proposed to make initializer lists different, or do I misunderstand or miss something?
It is new, yes. Take a look at [dcl.init.list].

In particular:

"If a narrowing conversion (see below) is required to convert any of the arguments, the program is ill-formed."

and

"A narrowing conversion is an implicit conversion...

from an integer type or unscoped enumeration type to an integer type that cannot represent all the
values of the original type, except where the source is a constant expression..."
Comment on attachment 554946 [details] [diff] [review]
add casts to gint

Thanks for filling me in on the details.
Attachment #554946 - Flags: review?(karlt) → review+
http://hg.mozilla.org/mozilla-central/rev/7099a6d4c871
Assignee: nobody → respindola
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla9
Version: unspecified → Trunk
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: