The binlog for a static_assert excludes the most important piece of information
See original GitHub issueIssue moved from dotnet/msbuild#8019
- Please respond to @dmachaj.
From @dmachaj on Friday, September 30, 2022 5:11:03 PM
Issue Description
We use some header files that have static asserts in them (see https://github.com/microsoft/wil). When those static asserts are violated there is a build break. The error output has the file/line information for the static_assert in WIL. However, the most important information is the file/line of the code in our project that uses WIL. This output is in the console but is missing from msbuild and the binlog file.
Steps to Reproduce
- Using Visual Studio 2022 17.3 create an empty Windows Console application project.
- Fill in the files as described below.
msbuild MSBuildOutputReproProject.sln /bl
- Open the msbuild.binlog file in the MSBuild Structured Log Viewer
ConsoleApplication1.cpp
#include <iostream>
#include "StaticAssertHeader.h"
int main()
{
std::cout << "Hello World!\n";
DoStuff(1);
DoStuff(1.0);
}
StaticAssertHeader.h
#pragma once
template <typename T>
void DoStuff(T value)
{
static_assert(std::is_same<T, int>());
}
Console output
ConsoleApplication1.cpp
v:\code\MSBuildOutputReproProject\ConsoleApplication1\StaticAssertHeader.h(6,39): error C2338: static_assert failed: 's
td::is_same<T, int>()' [v:\code\MSBuildOutputReproProject\ConsoleApplication1\ConsoleApplication1.vcxproj]
v:\code\MSBuildOutputReproProject\ConsoleApplication1\ConsoleApplication1.cpp(11): message : see reference to function
template instantiation 'void DoStuff<double>(T)' being compiled [v:\code\MSBuildOutputReproProject\ConsoleApplication1\
ConsoleApplication1.vcxproj]
with
[
T=double
]
Binlog content
v:\code\MSBuildOutputReproProject\ConsoleApplication1\StaticAssertHeader.h(6,39): error C2338: static_assert failed: 'std::is_same<T, int>()' [v:\code\MSBuildOutputReproProject\ConsoleApplication1\ConsoleApplication1.vcxproj]
see reference to function template instantiation 'void DoStuff<double>(T)' being compiled
with
[
T=double
]
The command exited with code 2.
Note that ConsoleApplication1.cpp(11)
is missing from the binlog. This is the most important piece of information in the output.
Expected Behavior
The binlog should contain the full set of compiler output. It is missing the most important line with the file/line information.
Actual Behavior
The file/line information for the calling code is missing. Without this it is not possible to locate the error in a large code base. I must pipe the output to a txt file and search it for the errors. That is a much worse experience than using the binlog viewer.
Analysis
Versions & Configurations
MSBuild version 17.3.1+2badb37d1 for .NET Framework 17.3.1.41501
This device is running Windows 11 (2022 update).
Issue Analytics
- State:
- Created a year ago
- Comments:9 (8 by maintainers)
Published in 2.1.728
Wow that was impressively fast. I just got a notice that there is a new version of the log viewer. When restarted it has your fix. I now see the expected information 👍