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

RESOLVED FIXED in mozilla9

Status

()

Core
Plug-ins
RESOLVED FIXED
6 years ago
6 years ago

People

(Reporter: espindola, Assigned: espindola)

Tracking

Trunk
mozilla9
x86_64
Linux
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

Created attachment 554946 [details] [diff] [review]
add casts to gint
Attachment #554946 - Flags: review?(karlt)
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+

Comment 5

6 years ago
http://hg.mozilla.org/mozilla-central/rev/7099a6d4c871
Assignee: nobody → respindola
Status: NEW → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla9
Version: unspecified → Trunk
You need to log in before you can comment on or make changes to this bug.