[Debichem-devel] Bug#728249: FTBFS on mips, mipsel and s390x due to -Werror=format-security

Aurelien Jarno aurel32 at debian.org
Tue Oct 29 22:16:58 UTC 2013


Package: mpqc
Version: 2.3.1-15
Severity: serious
Tags: patch upstream
Justification: fails to build from source (but built successfully in the past)

mpqc fails to build from source on mips, mipsel and s390x due to the
following error:

| atominfo.cc: In member function 'int sc::AtomInfo::string_to_Z(const string&, int)':
| atominfo.cc:496:75: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
|        ExEnv::err0() << sprintf("AtomInfo: invalid name: %s\n",name.c_str());
|                                                                            ^
| atominfo.cc:496:75: error: format not a string literal and no format arguments [-Werror=format-security]
| cc1plus: some warnings being treated as errors

Strangely this doesn't happen on other architectures where only the first warning is printed

| atominfo.cc: In member function 'int sc::AtomInfo::string_to_Z(const string&, int)':
| atominfo.cc:496:75: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

Looking at the (very weird) code, the error is obviously valid:

|      ExEnv::err0() << sprintf("AtomInfo: invalid name: %s\n",name.c_str());

Considering I understood what the upstream author wanted to do, here is
a patch to fix the issue:

--- mpqc-2.3.1.orig/src/lib/chemistry/molecule/atominfo.cc
+++ mpqc-2.3.1/src/lib/chemistry/molecule/atominfo.cc
@@ -493,7 +493,7 @@ AtomInfo::string_to_Z(const std::string
   if (iname != symbol_to_Z_.end()) return iname->second;

   if (allow_exceptions) {
-      ExEnv::err0() << sprintf("AtomInfo: invalid name: %s\n",name.c_str());
+      ExEnv::err0() << ("AtomInfo: invalid name: " + name + "\n").c_str();
       throw std::runtime_error("invalid atom name");
     }

-- System Information:
Debian Release: jessie/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: mipsel (mips64)

Kernel: Linux 3.2.0-4-5kc-malta
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash



More information about the Debichem-devel mailing list