Bad code in src/terminal/parser/ft_fuzzer/fuzzing_directed.h #17929

Closed
opened 2026-01-31 05:58:51 +00:00 by claunia · 3 comments
Owner

Originally created by @JonCavesMSFT on GitHub (Jul 14, 2022).

Windows Terminal version

No response

Windows build number

No response

Other Software

No response

Steps to reproduce

The code in question is on line 965:

return (this->m_fFuzzed) ? &(this->m_t) : &CFuzzType<_Type, _Args...>::m_tInit;

The Visual C++ compiler is correctly rejecting this code for two reasons: 1) the non-static data member 'm_tInit' is protected so the attempt to create the pointer-to-member will fail; and 2) even if it succeeds there is no way the compiler can bring the types associated with the left and right expressions of the ':' operator to a common type. I suspect that the code should be:

return (this->m_fFuzzed) ? &(this->m_t) : &(this->m_tInit);

Thanks
JonCaves

Expected Behavior

No response

Actual Behavior

The code fails to compile with a recent build of the Visual C++ compiler

Originally created by @JonCavesMSFT on GitHub (Jul 14, 2022). ### Windows Terminal version _No response_ ### Windows build number _No response_ ### Other Software _No response_ ### Steps to reproduce The code in question is on line 965: `return (this->m_fFuzzed) ? &(this->m_t) : &CFuzzType<_Type, _Args...>::m_tInit;` The Visual C++ compiler is correctly rejecting this code for two reasons: 1) the non-static data member '`m_tInit`' is protected so the attempt to create the pointer-to-member will fail; and 2) even if it succeeds there is no way the compiler can bring the types associated with the left and right expressions of the '`:`' operator to a common type. I suspect that the code should be: `return (this->m_fFuzzed) ? &(this->m_t) : &(this->m_tInit);` Thanks JonCaves ### Expected Behavior _No response_ ### Actual Behavior The code fails to compile with a recent build of the Visual C++ compiler
Author
Owner

@zadjii-msft commented on GitHub (Jul 14, 2022):

What version of the tools are you using? This seems to compile fine with VS 17.3.0 Preview 2.0...

Most of https://github.com/microsoft/terminal/blob/main/src/terminal/parser/ft_fuzzer/fuzzing_directed.h has been unchanged since we went open source, but INTERESTINGLY, that specific line was changed in #11816. In that PR, it was changed from what you suggest here to the current code. Link:https://github.com/microsoft/terminal/pull/11816/files#diff-5fbf1a284c85ac9a45b91d448ed5dc80ffc98cd56c82e9d40028e172d3681013L963

/cc @lhecker

@zadjii-msft commented on GitHub (Jul 14, 2022): What version of the tools are you using? This seems to compile fine with VS 17.3.0 Preview 2.0... Most of https://github.com/microsoft/terminal/blob/main/src/terminal/parser/ft_fuzzer/fuzzing_directed.h has been unchanged since we went open source, but INTERESTINGLY, that specific line _was_ changed in #11816. In that PR, it was changed from what you suggest here to the current code. Link:https://github.com/microsoft/terminal/pull/11816/files#diff-5fbf1a284c85ac9a45b91d448ed5dc80ffc98cd56c82e9d40028e172d3681013L963 /cc @lhecker
Author
Owner

@JonCavesMSFT commented on GitHub (Jul 14, 2022):

I am using the live compiler -- it will probably become 17.4 at some point. The intention of that PR appears to be to make the code more conformant and so in order for 2-phase name lookup to work for access to 'm_t' and 'm_tInit' they need to be made dependent -- and the best way to achieve this is to append 'this->'. The syntax '&CFuzzType<_Type, _Args...>::m_tInit' creates a pointer-to-member - what is not what it wanted in this situation.

JonCaves

@JonCavesMSFT commented on GitHub (Jul 14, 2022): I am using the live compiler -- it will probably become 17.4 at some point. The intention of that PR appears to be to make the code more conformant and so in order for 2-phase name lookup to work for access to '`m_t`' and '`m_tInit`' they need to be made dependent -- and the best way to achieve this is to append '`this->`'. The syntax '`&CFuzzType<_Type, _Args...>::m_tInit`' creates a pointer-to-member - what is not what it wanted in this situation. JonCaves
Author
Owner

@DHowett commented on GitHub (Jul 14, 2022):

Thanks for the heads up about 17.4!

@DHowett commented on GitHub (Jul 14, 2022): Thanks for the heads up about 17.4!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#17929