fputws to stderr crashes app

2

I'm kind of confused if I'm not doing anything wrong, but following code:

#include <stdio.h>

int main()
{
    fputws(L"this fails.\n", stderr);
    return 0;
}

crashes for me with the following exception:

Unhandled exception at 0x56BEDABC (msvcr110.dll) in errors.exe: 0xC0000005: Access violation reading location 0x000000A4.

I'm using MSVC2012.

I tried to

  • switch debug/release modes (both crashes)
  • stderr/stdout (both crashes)
  • switch x86/x64 (both crashes)
  • add /subsystem:console to linker (crashes)
  • compile in MSVC2010 - it works!

I've got following version:

Microsoft Visual Studio Professional 2012
Version 11.0.50727.1 RTMREL
Microsoft .NET Framework
Version 4.5.50709
c
visual-studio-2012
asked on Stack Overflow Sep 2, 2013 by nothrow

1 Answer

4

I finally managed to google the issue, but it wasn't mentioned on SO before, so the link is following:

http://connect.microsoft.com/VisualStudio/feedback/details/772585/fputws-yields-access-violation

VS2012update1 fixes the problem. msvcr110d.dll version is 11.00.51106.1.

Another workaround is to use fputs("", stderr); before using the fwputs, to initialize the IO streams properly.

answered on Stack Overflow Sep 2, 2013 by nothrow • edited Sep 2, 2013 by nothrow

User contributions licensed under CC BY-SA 3.0