New issue
Advanced search Search tips

Issue 703506 link

Starred by 1 user

Issue metadata

Status: Assigned
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 3
Type: Bug



Sign in to add a comment

base::StringPrintf fails silently on Windows (using %1$s, %2$s)

Project Member Reported by kolos@chromium.org, Mar 21 2017

Issue description


This code fails on windows bots and doesn't print any error: 
std::string script = base::StringPrintf(
  "var %1$s_%2$s_event = 0;"
  "document.getElementById('%1$s').on%2$s = function() {"
  "  %1$s_%2$s_event = 1;"
  "};\n",
  element_name, event);
https://codereview.chromium.org/2750323003/#ps40001 (	chrome/renderer/autofill/password_generation_test_utils.cc)


This code works:
std::string script = base::StringPrintf(
  "%s_%s_event = 0;"
  "document.getElementById('%s').on%s = function() {"
  "  %s_%s_event = 1;"
  "};",
  element_name, event, element_name, event, element_name, event);

What is the expected result?
The code should work since it works on Linux, or print a error message.

What happens instead?
The code fails w/o any output.


 
Cc: thestig@chromium.org
Owner: thakis@chromium.org
Not sure why I got the bug assignment. Based on my research, we took out support for positional parameters in r314963. I'll let thakis@ deal with this and probably mark it WontFix. If that's the case, we should add a note to stringprintf.h to mention the input needs to stay portable.

Comment 2 by kolos@chromium.org, Mar 24 2017

Thanks for info thestig@. 

I believe a note to stringprintf might be not enough. A developer might not take a look at the declaration  of stringprintf. It would be nice if the function cause run-time error (compilation error is not possible as I understand).

Sign in to add a comment