Last Comment Bug 681036 - Fix c++0x initializer list error found by clang
: Fix c++0x initializer list error found by clang
Status: RESOLVED FIXED
:
Product: Core
Classification: Components
Component: Plug-ins (show other bugs)
: Trunk
: x86_64 Linux
: -- normal (vote)
: mozilla9
Assigned To: Rafael Ávila de Espíndola (:espindola) (not reading bugmail)
:
: Benjamin Smedberg [:bsmedberg]
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-08-22 13:32 PDT by Rafael Ávila de Espíndola (:espindola) (not reading bugmail)
Modified: 2011-08-24 17:20 PDT (History)
2 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
add casts to gint (647 bytes, patch)
2011-08-22 13:32 PDT, Rafael Ávila de Espíndola (:espindola) (not reading bugmail)
karlt: review+
Details | Diff | Splinter Review

Description Rafael Ávila de Espíndola (:espindola) (not reading bugmail) 2011-08-22 13:32:21 PDT
Created attachment 554946 [details] [diff] [review]
add casts to gint
Comment 1 Rafael Ávila de Espíndola (:espindola) (not reading bugmail) 2011-08-22 13:35:19 PDT
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.
Comment 2 Karl Tomlinson (:karlt) 2011-08-23 00:12:46 PDT
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?
Comment 3 Rafael Ávila de Espíndola (:espindola) (not reading bugmail) 2011-08-23 08:33:16 PDT
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 4 Karl Tomlinson (:karlt) 2011-08-23 18:14:22 PDT
Comment on attachment 554946 [details] [diff] [review]
add casts to gint

Thanks for filling me in on the details.
Comment 5 Ed Morley [:emorley] 2011-08-24 17:20:35 PDT
http://hg.mozilla.org/mozilla-central/rev/7099a6d4c871

Note You need to log in before you can comment on or make changes to this bug.