C++是否在简单的POD typedef 上进行值初始化?
假设
typedef T* Ptr;
Run Code Online (Sandbox Code Playgroud)
不
Ptr()
Run Code Online (Sandbox Code Playgroud)
做值初始化并保证相等(T*)0?
例如
Ptr p = Ptr();
return Ptr();
Run Code Online (Sandbox Code Playgroud) 以下C代码说明了我在Linux 2.6.30.5-43.fc11.x86_64上看到的问题:
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int main() {
char buf[1024];
void *base;
int fd;
size_t pagesz = sysconf(_SC_PAGE_SIZE);
fd = open("<some file, at least 4*pagesz in length>", O_RDONLY);
if (fd < 0) {
perror("open");
return 1;
}
base = mmap(0, 4*pagesz, PROT_READ, MAP_SHARED, fd, 0);
if (base < 0) {
perror("mmap");
close(fd);
return 1;
}
memcpy(buf, (char*)base + 2*pagesz, 1024);
if (remap_file_pages(base, pagesz, 0, 2, 0) < …Run Code Online (Sandbox Code Playgroud)