Skip to content

noop_snippet: qualify std::vector - #71

Merged
bbiiggppiigg merged 1 commit into
masterfrom
bbiiggppiigg/noop-snippet-std-vector
Nov 23, 2026
Merged

bbiiggppiigg merged 1 commit into
masterfrom
bbiiggppiigg/noop-snippet-std-vector

Conversation

@bbiiggppiigg

Copy link
Copy Markdown
Member

How we found it

dyninst/dyninst#2629 removes the global-scope using-directives and std using-declarations from Dyninst's installed headers. Built against that install, with #70 already merged, this repository still fails in one file:

insertSnippet/noop_snippet.cpp:51:3: error: 'vector' was not declared in this scope

What is wrong

noop_snippet.cpp uses vector unqualified. It compiles today only because the installed PatchCommon.h (included through PatchMgr.h) has using std::vector; at global scope.

How we fixed it

Write std::vector. The file builds against Dyninst with or without dyninst/dyninst#2629, so this can merge first.

Validation

On d87a809, all 50 targets built on mahir (x86_64, gcc), with 0 errors and 0 warnings:

Not built on aarch64 or ppc64le; the change has no architecture-specific part.

🤖 Generated with Claude Code

noop_snippet.cpp uses vector unqualified. It only compiles because
Dyninst's installed PatchCommon.h (included through PatchMgr.h) has
"using std::vector;" at global scope. dyninst/dyninst#2629 removes the
std using-declarations from the installed headers, and with it this
file fails to build:

  noop_snippet.cpp:51:3: error: 'vector' was not declared in this scope

Write std::vector. It compiles against Dyninst with or without that
change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bbiiggppiigg
bbiiggppiigg merged commit 8f99274 into master Nov 23, 2026
1 check passed
bbiiggppiigg added a commit to dyninst/dyninst that referenced this pull request Nov 24, 2026
…#2629)

Seven installed headers put names into every consumer's scope:

- ABI.h, InstructionCache.h, liveness.h and local_var.h had
  "using namespace Dyninst;" (and Dyninst::InstructionAPI, SymtabAPI,
  Stackwalker) at global scope.
- PatchCommon.h had "using std::map; using std::set; using std::vector;
  using std::cerr;" at global scope.
- Dereference.h and BinaryFunction.h had "using std::vector;" inside
  Dyninst::InstructionAPI, which a consumer's
  "using namespace Dyninst::InstructionAPI;" carries into its own scope.

A program including one of them got those names in its scope, where
they can collide with its own names or another library's.
For example, adding a namespace Dyninst::abi made boost's use of the
"abi" from <cxxabi.h> ambiguous for every consumer of ABI.h.

Remove them and qualify the names instead, in these headers, in
PatchCFG.h, and in the internal sources and the dataflowAPI Slicing docs
example that relied on them. The classes and functions the headers
declare keep their names and stay at global scope; the ABI is unchanged.

Consumers that used Dyninst or std names unqualified through these
headers must now qualify them or add their own using-directive.
dyninst/examples#70 and dyninst/examples#71 did that for the examples.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants