diff --git a/Library/Homebrew/extend/ENV/shared.rb b/Library/Homebrew/extend/ENV/shared.rb
index c258e9f34f8fe58045dd0c7decfcfcb08046abdc..eb87efc9e2dffb89f97cb48eb50ad633d429145c 100644
--- a/Library/Homebrew/extend/ENV/shared.rb
+++ b/Library/Homebrew/extend/ENV/shared.rb
@@ -113,7 +113,7 @@ module SharedEnvExtension
   # an alternate compiler, altering the value of environment variables.
   # If no valid compiler is found, raises an exception.
   def validate_cc!(formula)
-    if formula.fails_with? ENV.compiler
+    if formula.fails_with? compiler
       send CompilerSelector.new(formula).compiler
     end
   end