apache / apache/brpc

error: cannot initialize return object of type 'uint64_t' (aka 'unsigned long') with an rvalue of type 'pthread_t'

Open
#2,071 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
17.6k
Forks
4.1k
Avg merge
2d 12h
Merged PRs (30d)
69

Description

**Describe the bug (描述bug)**
```
/usr/ports/devel/brpc/work/incubator-brpc-1.3.0/src/butil/compat.h:85:12: error: cannot initialize return object of type 'uint64_t' (aka 'unsigned long') with an rvalue of type 'pthread_t' (aka 'pthread *')
return pthread_self();
^~~~~~~~~~~~~~
2 errors generated.
``

**To Reproduce (复现方法)**
build on FreeBSD

According to the documentation pthread_self returns pthread_t:
```
NAME
pthread_self – get the calling thread's ID

LIBRARY
POSIX Threads Library (libpthread, -lpthread)

SYNOPSIS
#include

pthread_t
pthread_self(void);
```
pthread_t generally can not and should not be typecast to any other type.

**Versions (各种版本)**
OS: FreeBSD 13.1
Compiler: clang-14
brpc: 1.3.0

Contributor guide

Open the contributing guide

Research direction

Start with src/butil/compat.h at line 85 and reproduce the build on FreeBSD 13.1 with clang-14, as described in the issue. Check the pthread_self return type and the surrounding compatibility code; done means brpc 1.3.0 builds without this error on FreeBSD.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
operating-systems
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.