diff --git a/lib/AST/MicrosoftMangle.cpp b/lib/AST/MicrosoftMangle.cpp
index 3765f30..85accd0 100644
--- a/lib/AST/MicrosoftMangle.cpp
+++ b/lib/AST/MicrosoftMangle.cpp
@@ -343,6 +343,8 @@ void MicrosoftCXXNameMangler::mangleNumber(const llvm::APSInt &Value) {
   if (Value.uge(1) && Value.ule(10)) {
     --Temp;
     Temp.print(Out, false);
+  } else if (Value.getActiveBits() == 0) {
+    Out << "A@";
   } else {
     // We have to build up the encoding in reverse order, so it will come
     // out right when we write it out.
diff --git a/test/CodeGenCXX/mangle-ms-templates.cpp b/test/CodeGenCXX/mangle-ms-templates.cpp
index efe9565..e16fe93 100644
--- a/test/CodeGenCXX/mangle-ms-templates.cpp
+++ b/test/CodeGenCXX/mangle-ms-templates.cpp
@@ -48,6 +48,9 @@ void template_mangling() {
 // CHECK: call {{.*}} @"\01??0?$BoolTemplate@$00@@QAE@XZ"
 // CHECK: call {{.*}} @"\01??$Foo@H@?$BoolTemplate@$00@@QAEXH@Z"
 
+  IntTemplate<0> zero;
+// CHECK: call {{.*}} @"\01??0?$IntTemplate@$0A@@@QAE@XZ"
+
   IntTemplate<5> five;
 // CHECK: call {{.*}} @"\01??0?$IntTemplate@$04@@QAE@XZ"
 
