Reviewers: Vyacheslav Egorov,

Message:
Part two of the effort to make v8 buildable with GCC "4.7.0 (experimental)",
which also included filling two PR (problem reports) at gcc.gnu.org about
internal compiler errors (one is already fixed).

"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
and the actual value after conversion will fit into the target type and will
produce the original value when converted back to the original type."

That was violated for the generated geni/snapshot.cc: The values were negative
(generated from signed char) but the data type was "byte" which has been
typedefed as unsigned.

Description:
Fix GCC 4.7 warnings, which are related to char being signed in GCC
("narrowing conversion ... inside { } is ill-formed in C++11").

* src/mksnapshot.cc: Change "char" to "unsigned char" for data_ as
  generated data used the "byte" type, which is unsigned.
* test/cctest/test-regexp.cc: Use static_cast to uc16 as the char
  literal is signed.

Please review this at http://codereview.chromium.org/8825003/

SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/

Affected files:
  M     src/mksnapshot.cc


Index: src/mksnapshot.cc
===================================================================
--- src/mksnapshot.cc   (revision 10182)
+++ src/mksnapshot.cc   (working copy)
@@ -87,8 +87,8 @@
 class Compressor {
  public:
   virtual ~Compressor() {}
-  virtual bool Compress(i::Vector<char> input) = 0;
-  virtual i::Vector<char>* output() = 0;
+  virtual bool Compress(i::Vector<unsigned char> input) = 0;
+  virtual i::Vector<unsigned char>* output() = 0;
 };


@@ -112,7 +112,7 @@
       fprintf(fp, "%d", at(j));
     }
   }
-  char at(int i) { return data_[i]; }
+  unsigned char at(int i) { return data_[i]; }
   bool Compress(Compressor* compressor) {
     ASSERT_EQ(-1, raw_size_);
     raw_size_ = data_.length();
@@ -124,7 +124,7 @@
   int raw_size() { return raw_size_; }

  private:
-  i::List<char> data_;
+  i::List<unsigned char> data_;
   int raw_size_;
 };

@@ -232,9 +232,9 @@
   virtual ~BZip2Compressor() {
     delete output_;
   }
-  virtual bool Compress(i::Vector<char> input) {
+  virtual bool Compress(i::Vector<unsigned char> input) {
     delete output_;
- output_ = new i::ScopedVector<char>((input.length() * 101) / 100 + 1000); + output_ = new i::ScopedVector<unsigned char>((input.length() * 101) / 100 + 1000);
     unsigned int output_length_ = output_->length();
int result = BZ2_bzBuffToBuffCompress(output_->start(), &output_length_,
                                           input.start(), input.length(),
@@ -247,10 +247,10 @@
       return false;
     }
   }
-  virtual i::Vector<char>* output() { return output_; }
+  virtual i::Vector<unsigned char>* output() { return output_; }

  private:
-  i::ScopedVector<char>* output_;
+  i::ScopedVector<unsigned char>* output_;
 };


@@ -259,7 +259,7 @@
   virtual ~BZip2Decompressor() { }

  protected:
-  virtual int DecompressData(char* raw_data,
+  virtual int DecompressData(unsigned char* raw_data,
                              int* raw_data_size,
                              const char* compressed_data,
                              int compressed_data_size) {
@@ -269,7 +269,7 @@
     int result =
         BZ2_bzBuffToBuffDecompress(raw_data,
                                    &decompressed_size,
-                                   const_cast<char*>(compressed_data),
+ const_cast<unsigned char*>(compressed_data),
                                    compressed_data_size,
                                    0, 1);
     if (result == BZ_OK) {


--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to