diff -Nru aria2-1.14.2/debian/changelog aria2-1.14.2/debian/changelog
--- aria2-1.14.2/debian/changelog	2012-03-18 08:33:25.000000000 +0000
+++ aria2-1.14.2/debian/changelog	2012-04-04 22:00:43.000000000 +0000
@@ -1,3 +1,12 @@
+aria2 (1.14.2-1.1) UNRELEASED; urgency=low
+
+  * Non-maintainer upload.
+  * Fix FTBFS with gcc 4.7 (Closes: #667102):
+    - Move some declarations before the code that uses them.
+    - Fix missing <unistd.h> include.
+
+ -- Cyril Brulebois <kibi@debian.org>  Wed, 04 Apr 2012 22:00:00 +0000
+
 aria2 (1.14.2-1) unstable; urgency=low
 
   * New upstream release.
diff -Nru aria2-1.14.2/debian/patches/fix-ftbfs-with-gcc-4.7 aria2-1.14.2/debian/patches/fix-ftbfs-with-gcc-4.7
--- aria2-1.14.2/debian/patches/fix-ftbfs-with-gcc-4.7	1970-01-01 00:00:00.000000000 +0000
+++ aria2-1.14.2/debian/patches/fix-ftbfs-with-gcc-4.7	2012-04-04 22:01:37.000000000 +0000
@@ -0,0 +1,118 @@
+Description: Fix FTBFS with gcc 4.7
+ Move some declarations before the code that uses them.
+ Fix missing <unistd.h> include.
+Author: Cyril Brulebois <kibi@debian.org>
+Bug-Debian: http://bugs.debian.org/667102
+
+--- aria2-1.14.2.orig/src/DHTConnectionImpl.h
++++ aria2-1.14.2/src/DHTConnectionImpl.h
+@@ -35,6 +35,8 @@
+ #ifndef D_DHT_CONNECTION_IMPL_H
+ #define D_DHT_CONNECTION_IMPL_H
+ 
++#include <unistd.h>
++
+ #include "DHTConnection.h"
+ #include "SharedHandle.h"
+ #include "SegList.h"
+--- aria2-1.14.2.orig/src/util.h
++++ aria2-1.14.2/src/util.h
+@@ -111,6 +111,49 @@ std::string nativeToUtf8(const std::stri
+ 
+ namespace util {
+ 
++extern const std::string DEFAULT_STRIP_CHARSET;
++
++template<typename InputIterator>
++std::pair<InputIterator, InputIterator> stripIter
++(InputIterator first, InputIterator last,
++ const std::string& chars = DEFAULT_STRIP_CHARSET)
++{
++  for(; first != last &&
++        std::find(chars.begin(), chars.end(), *first) != chars.end(); ++first);
++  if(first == last) {
++    return std::make_pair(first, last);
++  }
++  InputIterator left = last-1;
++  for(; left != first &&
++        std::find(chars.begin(), chars.end(), *left) != chars.end(); --left);
++  return std::make_pair(first, left+1);
++}
++
++template<typename InputIterator>
++InputIterator lstripIter
++(InputIterator first, InputIterator last, char ch)
++{
++  for(; first != last && *first == ch; ++first);
++  return first;
++}
++
++template<typename InputIterator, typename InputIterator2>
++InputIterator lstripIter
++(InputIterator first, InputIterator last,
++ InputIterator2 cfirst, InputIterator2 clast)
++{
++  for(; first != last && std::find(cfirst, clast, *first) != clast; ++first);
++  return first;
++}
++
++template<typename InputIterator>
++InputIterator lstripIter
++(InputIterator first, InputIterator last)
++{
++  return lstripIter(first, last,
++                    DEFAULT_STRIP_CHARSET.begin(), DEFAULT_STRIP_CHARSET.end());
++}
++
+ template<typename InputIterator>
+ void divide
+ (std::pair<std::pair<InputIterator, InputIterator>,
+@@ -161,48 +204,6 @@ std::string itos(int64_t value, bool com
+ int64_t difftv(struct timeval tv1, struct timeval tv2);
+ int32_t difftvsec(struct timeval tv1, struct timeval tv2);
+ 
+-extern const std::string DEFAULT_STRIP_CHARSET;
+-
+-template<typename InputIterator>
+-std::pair<InputIterator, InputIterator> stripIter
+-(InputIterator first, InputIterator last,
+- const std::string& chars = DEFAULT_STRIP_CHARSET)
+-{
+-  for(; first != last &&
+-        std::find(chars.begin(), chars.end(), *first) != chars.end(); ++first);
+-  if(first == last) {
+-    return std::make_pair(first, last);
+-  }
+-  InputIterator left = last-1;
+-  for(; left != first &&
+-        std::find(chars.begin(), chars.end(), *left) != chars.end(); --left);
+-  return std::make_pair(first, left+1);
+-}
+-
+-template<typename InputIterator>
+-InputIterator lstripIter
+-(InputIterator first, InputIterator last, char ch)
+-{
+-  for(; first != last && *first == ch; ++first);
+-  return first;
+-}
+-
+-template<typename InputIterator, typename InputIterator2>
+-InputIterator lstripIter
+-(InputIterator first, InputIterator last,
+- InputIterator2 cfirst, InputIterator2 clast)
+-{
+-  for(; first != last && std::find(cfirst, clast, *first) != clast; ++first);
+-  return first;
+-}
+-
+-template<typename InputIterator>
+-InputIterator lstripIter
+-(InputIterator first, InputIterator last)
+-{
+-  return lstripIter(first, last,
+-                    DEFAULT_STRIP_CHARSET.begin(), DEFAULT_STRIP_CHARSET.end());
+-}
+ 
+ std::string strip
+ (const std::string& str, const std::string& chars = DEFAULT_STRIP_CHARSET);
diff -Nru aria2-1.14.2/debian/patches/series aria2-1.14.2/debian/patches/series
--- aria2-1.14.2/debian/patches/series	1970-01-01 00:00:00.000000000 +0000
+++ aria2-1.14.2/debian/patches/series	2012-04-04 22:00:59.000000000 +0000
@@ -0,0 +1 @@
+fix-ftbfs-with-gcc-4.7
