Failing to emit line directive if included file has a #if or #define on the first line
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
Research direction
Reproduce the issue with the provided a.cpp, if.h, and def.h inputs using both default_preprocessing_hooks and eat_whitespace. Then trace Wave's line-directive handling for an included file whose first emitted content follows a single #if, #ifdef, or #define. Done means the output includes the expected #line entries for if.h and def.h, while existing multiple-directive behavior remains correct.
Written by the indexing model from the issue text.
Description
Wave is not emitting the line directive if the first line in the included file is a #if or #ifdef that evaluates true and has content in its block. Likewise, it won't emit the line directive if the first line is a #define. This issue only occurs if there are not multiple #define or #if occurring on subsequent lines.
When using default_preprocessing_hooks, the above applies if the #if/#ifdef/#define is the first non-empty line or non-comment line. Essentially, if the directive immediately precedes the first content emitted from the included file. With eat_whitespace, the directive must be on the very first line of the include file to exhibit the issue.
Not sure if I've explained it very well, but I think an example will help better demonstrate the issue.
Example:
a.cpp
#include "if.h"
#include "def.h"
test
if.h
#if 1 //This must be on the first line for eat_whitespace, can be on 2nd, 3rd etc, for default_preprocessing_hooks as long as it's whitespace before it
if_h
#endif
def.h
#define A
def_h
Resulting preprocessed file:
a.preproc
if_h
def_h
Expected output:
#line 2 "if.h"
if_h
#line 2 "def.h"
def_h
As mentioned, the line directives do get emitted correctly if the include file is something like this:
#define A
#define B
content
So it's only occurring when there's a single directive at the beginning.
- Dominant language
- C++
- Stars
- 29
- Forks
- 56
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 4
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from boostorg/wave
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 3/5 1-2 days Newbie friendliness 65/100
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
context::set_language does not correctly set __cplusplusPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 3/5 1-2 days Newbie friendliness 56/100
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Qiskit/qiskit-aer#2466 ·
-
feature request
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 2 days
-
status:needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
PX4/PX4-Autopilot#29006 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Segfault in pwStreamAddBuffer: createBuffer() returning nullptr is dereferenced (Screencopy.cpp:943)Open
Difficulty 2/5 1-3 hours Newbie friendliness 74/100